summaryrefslogtreecommitdiff
path: root/django/utils/encoding.py
diff options
context:
space:
mode:
authorAymeric Augustin <aymeric.augustin@m4x.org>2012-09-07 11:45:25 -0400
committerAymeric Augustin <aymeric.augustin@m4x.org>2012-09-07 11:45:25 -0400
commit376a18993b7d4f7de82c8fa82c0be32961d9f397 (patch)
tree1b598d329ec10aff618fa0096aebcf6eb5e8682b /django/utils/encoding.py
parent53f533f8648eb869978020c11f0c9c8f4dae4679 (diff)
[1.4.x] [py3] Added forwards-compatible aliases.
Related documentation will go to the master branch, since there's no Python 3 documentation in the 1.5 branch.
Diffstat (limited to 'django/utils/encoding.py')
-rw-r--r--django/utils/encoding.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/django/utils/encoding.py b/django/utils/encoding.py
index 36e0da2915..292472320d 100644
--- a/django/utils/encoding.py
+++ b/django/utils/encoding.py
@@ -183,3 +183,15 @@ try:
codecs.lookup(DEFAULT_LOCALE_ENCODING)
except:
DEFAULT_LOCALE_ENCODING = 'ascii'
+
+# Forwards compatibility with Django 1.5
+
+def python_2_unicode_compatible(klass):
+ # Always use the Python 2 branch of the decorator here in Django 1.4
+ klass.__unicode__ = klass.__str__
+ klass.__str__ = lambda self: self.__unicode__().encode('utf-8')
+ return klass
+
+smart_text = smart_unicode
+force_text = force_unicode
+smart_bytes = smart_str