Skip to content

Fixed #18269 -- Applied unicode_literals for Python 3 compatibility. #86

Closed
wants to merge 1 commit into from

4 participants

@claudep
Django member
claudep commented May 21, 2012

In Python 3, all strings without prefix are considered Unicode.
Importing unicode_literals mimics this behavior in Python 2,
rendering the code more Python 3 compatible.

@claudep claudep Fixed #18269 -- Applied unicode_literals for Python 3 compatibility.
In Python 3, all strings without prefix are considered Unicode.
Importing unicode_literals mimics this behavior in Python 2,
rendering the code more Python 3 compatible.
f0bc3d1
@jezdez jezdez was assigned May 21, 2012
@alex
Django member
alex commented May 21, 2012

I started reviewing this patch by hand, but I realized it would take about 50 hours, so if all tests pass it looks fine to me. As soon as we have the test suite running (even if ther'es a bunch of failures) we should get a buildbot going.

@claudep
Django member
claudep commented May 21, 2012

Alex, this will not be enough to let the test suite even start on Python 3. We'll still have to add the utils/py3.py compatibility layer, then applying at least a bunch of syntax fixes (metaclass, reraise exceptions, etc.).

@alex
Django member
alex commented May 21, 2012

Right I was just thinking outloud, for the future.

@akaariai
Django member

Not directly related to this pull, but how are we going to guarantee that we do not introduce additional unicode literals (or other py3 incompatible changes) in the future. django-developers question maybe?

@alex
Django member
alex commented May 22, 2012

Once we can run tests on py3k that will let us know, until then we just have to be careful.

@jezdez jezdez commented on the diff Jun 7, 2012
django/conf/locale/bg/formats.py
@@ -2,6 +2,8 @@
# This file is distributed under the same license as the Django package.
#
@jezdez
Django member
jezdez added a note Jun 7, 2012

Unneeded empty line.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@jezdez jezdez commented on the diff Jun 7, 2012
django/conf/locale/fi/formats.py
@@ -2,6 +2,8 @@
# This file is distributed under the same license as the Django package.
#
@jezdez
Django member
jezdez added a note Jun 7, 2012

Unneeded empty line.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@jezdez jezdez commented on the diff Jun 7, 2012
django/conf/locale/hu/formats.py
@@ -2,6 +2,8 @@
# This file is distributed under the same license as the Django package.
#
@jezdez
Django member
jezdez added a note Jun 7, 2012

Unneeded empty line.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@jezdez jezdez commented on the diff Jun 7, 2012
django/conf/locale/lv/formats.py
@@ -2,6 +2,8 @@
# This file is distributed under the same license as the Django package.
#
@jezdez
Django member
jezdez added a note Jun 7, 2012

Unneeded empty line.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@jezdez jezdez commented on the diff Jun 7, 2012
django/conf/locale/pl/formats.py
@@ -2,6 +2,8 @@
# This file is distributed under the same license as the Django package.
#
@jezdez
Django member
jezdez added a note Jun 7, 2012

Unneeded empty line.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@jezdez jezdez commented on the diff Jun 7, 2012
django/contrib/webdesign/tests.py
@@ -1,5 +1,7 @@
# -*- coding: utf-8 -*-
@jezdez
Django member
jezdez added a note Jun 7, 2012

Unneeded empty line.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@jezdez jezdez commented on the diff Jun 7, 2012
django/forms/widgets.py
for path in self._css[medium]]
for medium in media])
def absolute_path(self, path, prefix=None):
- if path.startswith(u'http://') or path.startswith(u'https://') or path.startswith(u'/'):
@jezdez
Django member
jezdez added a note Jun 7, 2012

Could probably be a tuple now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@jezdez jezdez commented on the diff Jun 7, 2012
django/utils/dateformat.py
@@ -11,6 +11,8 @@
>>>
"""
@jezdez
Django member
jezdez added a note Jun 7, 2012

Unneeded empty line.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@jezdez jezdez commented on the diff Jun 7, 2012
docs/ref/unicode.txt
@@ -45,6 +45,26 @@ rendering or anywhere else -- you have two choices for encoding those strings.
You can use Unicode strings, or you can use normal strings (sometimes called
"bytestrings") that are encoded using UTF-8.
+In Python 3, the logic is reversed, that is normal strings are Unicode, and
@jezdez
Django member
jezdez added a note Jun 7, 2012

A .. versionchanged:: 1.5 directive here would be very useful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@jezdez jezdez commented on the diff Jun 7, 2012
tests/modeltests/expressions/models.py
@@ -2,6 +2,8 @@
Tests for F() query expression syntax.
"""
@jezdez
Django member
jezdez added a note Jun 7, 2012

Unneeded empty line.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@jezdez jezdez commented on the diff Jun 7, 2012
tests/modeltests/m2m_intermediary/models.py
@@ -10,6 +10,8 @@
(e.g. "Staff writer").
"""
@jezdez
Django member
jezdez added a note Jun 7, 2012

Unneeded empty line.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@jezdez jezdez commented on the diff Jun 7, 2012
tests/modeltests/many_to_one/models.py
@@ -4,6 +4,8 @@
To define a many-to-one relationship, use ``ForeignKey()``.
"""
@jezdez
Django member
jezdez added a note Jun 7, 2012

Unneeded empty line.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@jezdez jezdez commented on the diff Jun 7, 2012
tests/modeltests/model_forms/models.py
@@ -7,6 +7,8 @@
words, most of these tests should be rewritten.
"""
@jezdez
Django member
jezdez added a note Jun 7, 2012

Unneeded empty line.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@jezdez jezdez commented on the diff Jun 7, 2012
tests/modeltests/model_inheritance/models.py
@@ -12,6 +12,8 @@
Both styles are demonstrated here.
"""
@jezdez
Django member
jezdez added a note Jun 7, 2012

Unneeded empty line.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@jezdez jezdez commented on the diff Jun 7, 2012
tests/modeltests/one_to_one/models.py
@@ -6,6 +6,8 @@
In this example, a ``Place`` optionally can be a ``Restaurant``.
"""
@jezdez
Django member
jezdez added a note Jun 7, 2012

Unneeded empty line.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@jezdez jezdez commented on the diff Jun 7, 2012
tests/modeltests/save_delete_hooks/models.py
@@ -5,6 +5,8 @@
the methods.
"""
@jezdez
Django member
jezdez added a note Jun 7, 2012

Unneeded empty line. Sigh, I think I should just say this in general :flushed:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@claudep
Django member
claudep commented Jun 7, 2012

Thanks a lot for the review. Pushed in 4a10308

@claudep claudep closed this Jun 7, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.