mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
Fixed #21574 -- Handle bytes consistently in utils.text.normalize_newlines.
All input is now coerced to text before being normalized. This changes nothing under Python 2 but it allows bytes to be passed to the function without a TypeError under Python3 (bytes are assumed to be utf-8 encoded text). Thanks to trac user vajrasky for the report.
This commit is contained in:
@@ -250,7 +250,9 @@ get_text_list = allow_lazy(get_text_list, six.text_type)
|
||||
|
||||
|
||||
def normalize_newlines(text):
|
||||
return force_text(re_newlines.sub('\n', text))
|
||||
"""Normalizes CRLF and CR newlines to just LF."""
|
||||
text = force_text(text)
|
||||
return re_newlines.sub('\n', text)
|
||||
normalize_newlines = allow_lazy(normalize_newlines, six.text_type)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user