summaryrefslogtreecommitdiff
path: root/django/utils/encoding.py
diff options
context:
space:
mode:
authorAymeric Augustin <aymeric.augustin@m4x.org>2012-08-12 14:39:48 +0200
committerAymeric Augustin <aymeric.augustin@m4x.org>2012-08-12 14:44:41 +0200
commit4e68e861533846010e372ecf58e3cd0439081754 (patch)
tree5611cdf2a7af452e08f5bf21f6faa03fa5320eb2 /django/utils/encoding.py
parentd4a0b27838c815af87698920cc4db7d2afd6f05b (diff)
[py3] Deprecated StrAndUnicode.
This mix-in is superseded by the @python_2_unicode_compatible decorator.
Diffstat (limited to 'django/utils/encoding.py')
-rw-r--r--django/utils/encoding.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/django/utils/encoding.py b/django/utils/encoding.py
index 7030ab1db0..633022dd3b 100644
--- a/django/utils/encoding.py
+++ b/django/utils/encoding.py
@@ -8,6 +8,7 @@ try:
from urllib.parse import quote
except ImportError: # Python 2
from urllib import quote
+import warnings
from django.utils.functional import Promise
from django.utils import six
@@ -32,6 +33,12 @@ class StrAndUnicode(object):
Useful as a mix-in. If you support Python 2 and 3 with a single code base,
you can inherit this mix-in and just define __unicode__.
"""
+ def __init__(self, *args, **kwargs):
+ warnings.warn("StrAndUnicode is deprecated. Define a __str__ method "
+ "and apply the @python_2_unicode_compatible decorator "
+ "instead.", PendingDeprecationWarning, stacklevel=2)
+ super(StrAndUnicode, self).__init__(*args, **kwargs)
+
if six.PY3:
def __str__(self):
return self.__unicode__()