Skip to content

Commit

Permalink
Fixed #18269 -- Applied unicode_literals for Python 3 compatibility.
Browse files Browse the repository at this point in the history
Thanks Vinay Sajip for the support of his django3 branch and
Jannis Leidel for the review.
  • Loading branch information
claudep committed Jun 7, 2012
1 parent 706fd9a commit 4a10308
Show file tree
Hide file tree
Showing 401 changed files with 6,647 additions and 6,157 deletions.
146 changes: 74 additions & 72 deletions django/conf/locale/__init__.py

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion django/conf/locale/bg/formats.py
@@ -1,6 +1,7 @@
# -*- encoding: utf-8 -*-
# This file is distributed under the same license as the Django package.
#
from __future__ import unicode_literals

# The *_FORMAT strings use the Django date format syntax,
# see http://docs.djangoproject.com/en/dev/ref/templates/builtins/#date
Expand All @@ -19,5 +20,5 @@
# TIME_INPUT_FORMATS =
# DATETIME_INPUT_FORMATS =
DECIMAL_SEPARATOR = ','
THOUSAND_SEPARATOR = u' ' # Non-breaking space
THOUSAND_SEPARATOR = ' ' # Non-breaking space
# NUMBER_GROUPING =
3 changes: 2 additions & 1 deletion django/conf/locale/cs/formats.py
@@ -1,6 +1,7 @@
# -*- encoding: utf-8 -*-
# This file is distributed under the same license as the Django package.
#
from __future__ import unicode_literals

# The *_FORMAT strings use the Django date format syntax,
# see http://docs.djangoproject.com/en/dev/ref/templates/builtins/#date
Expand Down Expand Up @@ -33,5 +34,5 @@
'%Y-%m-%d', # '2006-10-25'
)
DECIMAL_SEPARATOR = ','
THOUSAND_SEPARATOR = u'\xa0' # non-breaking space
THOUSAND_SEPARATOR = '\xa0' # non-breaking space
NUMBER_GROUPING = 3
4 changes: 2 additions & 2 deletions django/conf/locale/en/formats.py
Expand Up @@ -37,7 +37,7 @@
'%m/%d/%y %H:%M', # '10/25/06 14:30'
'%m/%d/%y', # '10/25/06'
)
DECIMAL_SEPARATOR = u'.'
THOUSAND_SEPARATOR = u','
DECIMAL_SEPARATOR = '.'
THOUSAND_SEPARATOR = ','
NUMBER_GROUPING = 3

3 changes: 2 additions & 1 deletion django/conf/locale/es_MX/formats.py
@@ -1,6 +1,7 @@
# -*- encoding: utf-8 -*-
# This file is distributed under the same license as the Django package.
#
from __future__ import unicode_literals

DATE_FORMAT = r'j \d\e F \d\e Y'
TIME_FORMAT = 'H:i:s'
Expand All @@ -24,5 +25,5 @@
'%d/%m/%y %H:%M',
)
DECIMAL_SEPARATOR = '.' # ',' is also official (less common): NOM-008-SCFI-2002
THOUSAND_SEPARATOR = u'\xa0' # non-breaking space
THOUSAND_SEPARATOR = '\xa0' # non-breaking space
NUMBER_GROUPING = 3
3 changes: 2 additions & 1 deletion django/conf/locale/et/formats.py
@@ -1,6 +1,7 @@
# -*- encoding: utf-8 -*-
# This file is distributed under the same license as the Django package.
#
from __future__ import unicode_literals

# The *_FORMAT strings use the Django date format syntax,
# see http://docs.djangoproject.com/en/dev/ref/templates/builtins/#date
Expand All @@ -19,5 +20,5 @@
# TIME_INPUT_FORMATS =
# DATETIME_INPUT_FORMATS =
DECIMAL_SEPARATOR = ','
THOUSAND_SEPARATOR = u' ' # Non-breaking space
THOUSAND_SEPARATOR = ' ' # Non-breaking space
# NUMBER_GROUPING =
3 changes: 2 additions & 1 deletion django/conf/locale/fi/formats.py
@@ -1,6 +1,7 @@
# -*- encoding: utf-8 -*-
# This file is distributed under the same license as the Django package.
#
from __future__ import unicode_literals

# The *_FORMAT strings use the Django date format syntax,
# see http://docs.djangoproject.com/en/dev/ref/templates/builtins/#date
Expand All @@ -19,5 +20,5 @@
# TIME_INPUT_FORMATS =
# DATETIME_INPUT_FORMATS =
DECIMAL_SEPARATOR = ','
THOUSAND_SEPARATOR = u' ' # Non-breaking space
THOUSAND_SEPARATOR = ' ' # Non-breaking space
# NUMBER_GROUPING =
3 changes: 2 additions & 1 deletion django/conf/locale/fr/formats.py
@@ -1,6 +1,7 @@
# -*- encoding: utf-8 -*-
# This file is distributed under the same license as the Django package.
#
from __future__ import unicode_literals

# The *_FORMAT strings use the Django date format syntax,
# see http://docs.djangoproject.com/en/dev/ref/templates/builtins/#date
Expand Down Expand Up @@ -37,5 +38,5 @@
'%Y-%m-%d', # '2006-10-25'
)
DECIMAL_SEPARATOR = ','
THOUSAND_SEPARATOR = u'\xa0' # non-breaking space
THOUSAND_SEPARATOR = '\xa0' # non-breaking space
NUMBER_GROUPING = 3
1 change: 1 addition & 0 deletions django/conf/locale/he/formats.py
@@ -1,6 +1,7 @@
# -*- encoding: utf-8 -*-
# This file is distributed under the same license as the Django package.
#
from __future__ import unicode_literals

# The *_FORMAT strings use the Django date format syntax,
# see http://docs.djangoproject.com/en/dev/ref/templates/builtins/#date
Expand Down
3 changes: 2 additions & 1 deletion django/conf/locale/hu/formats.py
@@ -1,6 +1,7 @@
# -*- encoding: utf-8 -*-
# This file is distributed under the same license as the Django package.
#
from __future__ import unicode_literals

# The *_FORMAT strings use the Django date format syntax,
# see http://docs.djangoproject.com/en/dev/ref/templates/builtins/#date
Expand Down Expand Up @@ -28,5 +29,5 @@
'%Y.%m.%d.', # '2006.10.25.'
)
DECIMAL_SEPARATOR = ','
THOUSAND_SEPARATOR = u' ' # Non-breaking space
THOUSAND_SEPARATOR = ' ' # Non-breaking space
NUMBER_GROUPING = 3
1 change: 1 addition & 0 deletions django/conf/locale/ja/formats.py
@@ -1,6 +1,7 @@
# -*- encoding: utf-8 -*-
# This file is distributed under the same license as the Django package.
#
from __future__ import unicode_literals

# The *_FORMAT strings use the Django date format syntax,
# see http://docs.djangoproject.com/en/dev/ref/templates/builtins/#date
Expand Down
1 change: 1 addition & 0 deletions django/conf/locale/km/formats.py
@@ -1,6 +1,7 @@
# -*- encoding: utf-8 -*-
# This file is distributed under the same license as the Django package.
#
from __future__ import unicode_literals

# The *_FORMAT strings use the Django date format syntax,
# see http://docs.djangoproject.com/en/dev/ref/templates/builtins/#date
Expand Down
1 change: 1 addition & 0 deletions django/conf/locale/ko/formats.py
@@ -1,6 +1,7 @@
# -*- encoding: utf-8 -*-
# This file is distributed under the same license as the Django package.
#
from __future__ import unicode_literals

# The *_FORMAT strings use the Django date format syntax,
# see http://docs.djangoproject.com/en/dev/ref/templates/builtins/#date
Expand Down
3 changes: 2 additions & 1 deletion django/conf/locale/lv/formats.py
@@ -1,6 +1,7 @@
# -*- encoding: utf-8 -*-
# This file is distributed under the same license as the Django package.
#
from __future__ import unicode_literals

# The *_FORMAT strings use the Django date format syntax,
# see http://docs.djangoproject.com/en/dev/ref/templates/builtins/#date
Expand Down Expand Up @@ -37,5 +38,5 @@
'%d.%m.%y', # '25.10.06'
)
DECIMAL_SEPARATOR = ','
THOUSAND_SEPARATOR = u' ' # Non-breaking space
THOUSAND_SEPARATOR = ' ' # Non-breaking space
NUMBER_GROUPING = 3
3 changes: 2 additions & 1 deletion django/conf/locale/nb/formats.py
@@ -1,6 +1,7 @@
# -*- encoding: utf-8 -*-
# This file is distributed under the same license as the Django package.
#
from __future__ import unicode_literals

# The *_FORMAT strings use the Django date format syntax,
# see http://docs.djangoproject.com/en/dev/ref/templates/builtins/#date
Expand Down Expand Up @@ -39,5 +40,5 @@
'%d.%m.%y', # '25.10.06'
)
DECIMAL_SEPARATOR = ','
THOUSAND_SEPARATOR = u'\xa0' # non-breaking space
THOUSAND_SEPARATOR = '\xa0' # non-breaking space
NUMBER_GROUPING = 3
3 changes: 2 additions & 1 deletion django/conf/locale/nn/formats.py
@@ -1,6 +1,7 @@
# -*- encoding: utf-8 -*-
# This file is distributed under the same license as the Django package.
#
from __future__ import unicode_literals

# The *_FORMAT strings use the Django date format syntax,
# see http://docs.djangoproject.com/en/dev/ref/templates/builtins/#date
Expand Down Expand Up @@ -39,5 +40,5 @@
'%d.%m.%y', # '25.10.06'
)
DECIMAL_SEPARATOR = ','
THOUSAND_SEPARATOR = u'\xa0' # non-breaking space
THOUSAND_SEPARATOR = '\xa0' # non-breaking space
NUMBER_GROUPING = 3
3 changes: 2 additions & 1 deletion django/conf/locale/pl/formats.py
@@ -1,6 +1,7 @@
# -*- encoding: utf-8 -*-
# This file is distributed under the same license as the Django package.
#
from __future__ import unicode_literals

# The *_FORMAT strings use the Django date format syntax,
# see http://docs.djangoproject.com/en/dev/ref/templates/builtins/#date
Expand Down Expand Up @@ -33,5 +34,5 @@
'%Y-%m-%d', # '2006-10-25'
)
DECIMAL_SEPARATOR = ','
THOUSAND_SEPARATOR = u' '
THOUSAND_SEPARATOR = ' '
NUMBER_GROUPING = 3
1 change: 1 addition & 0 deletions django/conf/locale/pt_BR/formats.py
@@ -1,6 +1,7 @@
# -*- encoding: utf-8 -*-
# This file is distributed under the same license as the Django package.
#
from __future__ import unicode_literals

# The *_FORMAT strings use the Django date format syntax,
# see http://docs.djangoproject.com/en/dev/ref/templates/builtins/#date
Expand Down
3 changes: 2 additions & 1 deletion django/conf/locale/ru/formats.py
@@ -1,6 +1,7 @@
# -*- encoding: utf-8 -*-
# This file is distributed under the same license as the Django package.
#
from __future__ import unicode_literals

# The *_FORMAT strings use the Django date format syntax,
# see http://docs.djangoproject.com/en/dev/ref/templates/builtins/#date
Expand Down Expand Up @@ -36,5 +37,5 @@
'%Y-%m-%d', # '2006-10-25'
)
DECIMAL_SEPARATOR = ','
THOUSAND_SEPARATOR = u'\xa0' # non-breaking space
THOUSAND_SEPARATOR = '\xa0' # non-breaking space
NUMBER_GROUPING = 3
3 changes: 2 additions & 1 deletion django/conf/locale/sk/formats.py
@@ -1,6 +1,7 @@
# -*- encoding: utf-8 -*-
# This file is distributed under the same license as the Django package.
#
from __future__ import unicode_literals

# The *_FORMAT strings use the Django date format syntax,
# see http://docs.djangoproject.com/en/dev/ref/templates/builtins/#date
Expand Down Expand Up @@ -33,5 +34,5 @@
'%Y-%m-%d', # '2006-10-25'
)
DECIMAL_SEPARATOR = ','
THOUSAND_SEPARATOR = u'\xa0' # non-breaking space
THOUSAND_SEPARATOR = '\xa0' # non-breaking space
NUMBER_GROUPING = 3
3 changes: 2 additions & 1 deletion django/conf/locale/sv/formats.py
@@ -1,6 +1,7 @@
# -*- encoding: utf-8 -*-
# This file is distributed under the same license as the Django package.
#
from __future__ import unicode_literals

# The *_FORMAT strings use the Django date format syntax,
# see http://docs.djangoproject.com/en/dev/ref/templates/builtins/#date
Expand Down Expand Up @@ -36,5 +37,5 @@
'%m/%d/%y', # '10/25/06'
)
DECIMAL_SEPARATOR = ','
THOUSAND_SEPARATOR = u'\xa0' # non-breaking space
THOUSAND_SEPARATOR = '\xa0' # non-breaking space
NUMBER_GROUPING = 3
4 changes: 3 additions & 1 deletion django/conf/locale/uk/formats.py
Expand Up @@ -2,6 +2,8 @@
# This file is distributed under the same license as the Django package.
#

from __future__ import unicode_literals

# The *_FORMAT strings use the Django date format syntax,
# see http://docs.djangoproject.com/en/dev/ref/templates/builtins/#date
DATE_FORMAT = 'j E Y р.'
Expand All @@ -19,5 +21,5 @@
# TIME_INPUT_FORMATS =
# DATETIME_INPUT_FORMATS =
DECIMAL_SEPARATOR = ','
THOUSAND_SEPARATOR = u' '
THOUSAND_SEPARATOR = ' '
# NUMBER_GROUPING =
1 change: 1 addition & 0 deletions django/conf/locale/vi/formats.py
@@ -1,6 +1,7 @@
# -*- encoding: utf-8 -*-
# This file is distributed under the same license as the Django package.
#
from __future__ import unicode_literals

# The *_FORMAT strings use the Django date format syntax,
# see http://docs.djangoproject.com/en/dev/ref/templates/builtins/#date
Expand Down
5 changes: 3 additions & 2 deletions django/contrib/admin/forms.py
@@ -1,9 +1,10 @@
from __future__ import unicode_literals

from django import forms

from django.contrib.auth import authenticate
from django.contrib.auth.forms import AuthenticationForm
from django.contrib.auth.models import User

from django.utils.translation import ugettext_lazy, ugettext as _

ERROR_MESSAGE = ugettext_lazy("Please enter the correct username and password "
Expand All @@ -25,7 +26,7 @@ def clean(self):
if username and password:
self.user_cache = authenticate(username=username, password=password)
if self.user_cache is None:
if u'@' in username:
if '@' in username:
# Mistakenly entered e-mail address instead of username? Look it up.
try:
user = User.objects.get(email=username)
Expand Down
18 changes: 10 additions & 8 deletions django/contrib/admin/helpers.py
@@ -1,3 +1,5 @@
from __future__ import unicode_literals

from django import forms
from django.contrib.admin.util import (flatten_fieldsets, lookup_field,
display_for_field, label_for_field, help_text_for_field)
Expand Down Expand Up @@ -69,7 +71,7 @@ def __init__(self, form, name=None, readonly_fields=(), fields=(), classes=(),
description=None, model_admin=None):
self.form = form
self.name, self.fields = name, fields
self.classes = u' '.join(classes)
self.classes = ' '.join(classes)
self.description = description
self.model_admin = model_admin
self.readonly_fields = readonly_fields
Expand Down Expand Up @@ -109,7 +111,7 @@ def __iter__(self):
yield AdminField(self.form, field, is_first=(i == 0))

def errors(self):
return mark_safe(u'\n'.join([self.form[f].errors.as_ul() for f in self.fields if f not in self.readonly_fields]).strip('\n'))
return mark_safe('\n'.join([self.form[f].errors.as_ul() for f in self.fields if f not in self.readonly_fields]).strip('\n'))

class AdminField(object):
def __init__(self, form, field, is_first):
Expand All @@ -121,14 +123,14 @@ def label_tag(self):
classes = []
contents = conditional_escape(force_unicode(self.field.label))
if self.is_checkbox:
classes.append(u'vCheckboxLabel')
classes.append('vCheckboxLabel')
else:
contents += u':'
contents += ':'
if self.field.field.required:
classes.append(u'required')
classes.append('required')
if not self.is_first:
classes.append(u'inline')
attrs = classes and {'class': u' '.join(classes)} or {}
classes.append('inline')
attrs = classes and {'class': ' '.join(classes)} or {}
return self.field.label_tag(contents=mark_safe(contents), attrs=attrs)

def errors(self):
Expand Down Expand Up @@ -161,7 +163,7 @@ def label_tag(self):
if not self.is_first:
attrs["class"] = "inline"
label = self.field['label']
contents = capfirst(force_unicode(escape(label))) + u":"
contents = capfirst(force_unicode(escape(label))) + ":"
return mark_safe('<label%(attrs)s>%(contents)s</label>' % {
"attrs": flatatt(attrs),
"contents": contents,
Expand Down
4 changes: 3 additions & 1 deletion django/contrib/admin/models.py
@@ -1,3 +1,5 @@
from __future__ import unicode_literals

from django.db import models
from django.contrib.contenttypes.models import ContentType
from django.contrib.auth.models import User
Expand Down Expand Up @@ -64,5 +66,5 @@ def get_admin_url(self):
This is relative to the Django admin index page.
"""
if self.content_type and self.object_id:
return mark_safe(u"%s/%s/%s/" % (self.content_type.app_label, self.content_type.model, quote(self.object_id)))
return mark_safe("%s/%s/%s/" % (self.content_type.app_label, self.content_type.model, quote(self.object_id)))
return None

0 comments on commit 4a10308

Please sign in to comment.