Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

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

Closed
wants to merge 1 commit into from

4 participants

@claudep
Collaborator

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
@alex
Collaborator

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
Collaborator

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
Collaborator

Right I was just thinking outloud, for the future.

@akaariai
Collaborator

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
Collaborator

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
django/conf/locale/bg/formats.py
@@ -2,6 +2,8 @@
# This file is distributed under the same license as the Django package.
#
@jezdez Owner
jezdez added a note

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
django/conf/locale/fi/formats.py
@@ -2,6 +2,8 @@
# This file is distributed under the same license as the Django package.
#
@jezdez Owner
jezdez added a note

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
django/conf/locale/hu/formats.py
@@ -2,6 +2,8 @@
# This file is distributed under the same license as the Django package.
#
@jezdez Owner
jezdez added a note

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
django/conf/locale/lv/formats.py
@@ -2,6 +2,8 @@
# This file is distributed under the same license as the Django package.
#
@jezdez Owner
jezdez added a note

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
django/conf/locale/pl/formats.py
@@ -2,6 +2,8 @@
# This file is distributed under the same license as the Django package.
#
@jezdez Owner
jezdez added a note

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
django/contrib/webdesign/tests.py
@@ -1,5 +1,7 @@
# -*- coding: utf-8 -*-
@jezdez Owner
jezdez added a note

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
django/forms/widgets.py
((6 lines not shown))
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 Owner
jezdez added a note

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
django/utils/dateformat.py
@@ -11,6 +11,8 @@
>>>
"""
@jezdez Owner
jezdez added a note

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
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 Owner
jezdez added a note

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
tests/modeltests/expressions/models.py
@@ -2,6 +2,8 @@
Tests for F() query expression syntax.
"""
@jezdez Owner
jezdez added a note

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
tests/modeltests/m2m_intermediary/models.py
@@ -10,6 +10,8 @@
(e.g. "Staff writer").
"""
@jezdez Owner
jezdez added a note

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
tests/modeltests/many_to_one/models.py
@@ -4,6 +4,8 @@
To define a many-to-one relationship, use ``ForeignKey()``.
"""
@jezdez Owner
jezdez added a note

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
tests/modeltests/model_forms/models.py
@@ -7,6 +7,8 @@
words, most of these tests should be rewritten.
"""
@jezdez Owner
jezdez added a note

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
tests/modeltests/model_inheritance/models.py
@@ -12,6 +12,8 @@
Both styles are demonstrated here.
"""
@jezdez Owner
jezdez added a note

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
tests/modeltests/one_to_one/models.py
@@ -6,6 +6,8 @@
In this example, a ``Place`` optionally can be a ``Restaurant``.
"""
@jezdez Owner
jezdez added a note

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
tests/modeltests/save_delete_hooks/models.py
@@ -5,6 +5,8 @@
the methods.
"""
@jezdez Owner
jezdez added a note

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
Collaborator

Thanks a lot for the review. Pushed in 4a10308

@claudep claudep closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on May 21, 2012
  1. @claudep

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

    claudep authored
    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.
Something went wrong with that request. Please try again.