﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
21574	Different behaviour in Python 2 and 3 when normalizing newlines with django.utils.text.normalize_newlines	Vajrasky Kok	Vajrasky Kok	"Python 3.3:

{{{
>>> from django.utils.text import normalize_newlines
>>> normalize_newlines(""abc\r\ndef"")
'abc\ndef'
>>> normalize_newlines(b""abc\r\ndef"")
Traceback (most recent call last):
  File ""<console>"", line 1, in <module>
  File ""/home/sky/Code/python/env/django/lib/python3.3/site-packages/django/utils/functional.py"", line 213, in wrapper
    return func(*args, **kwargs)
  File ""/home/sky/Code/python/env/django/lib/python3.3/site-packages/django/utils/text.py"", line 252, in normalize_newlines
    return force_text(re.sub(r'\r\n|\r|\n', '\n', text))
  File ""/usr/lib64/python3.3/re.py"", line 170, in sub
    return _compile(pattern, flags).sub(repl, string, count)
TypeError: can't use a string pattern on a bytes-like object
}}}

Python 2.7:

{{{
>>> from django.utils.text import normalize_newlines
>>> normalize_newlines(u""abc\r\ndef"")
u'abc\ndef'
>>> normalize_newlines(""abc\r\ndef"")
u'abc\ndef'
}}}

I can produce the patch but I need to know who is in fault here: Python 2 or Python 3? Should Python 2 rejects binary or should Python 3 accepts binary?"	Bug	closed	Utilities	dev	Normal	fixed		sky.kok@…	Unreviewed	0	0	0	0	1	0
