diff --git a/django/utils/encoding.py b/django/utils/encoding.py
index 599952b..2e07c87 100644
a
|
b
|
class StrAndUnicode(object):
|
43 | 43 | def __str__(self): |
44 | 44 | return self.__unicode__().encode('utf-8') |
45 | 45 | |
| 46 | class _Python_2_Unicode_Compatible_Str(object): |
| 47 | def __call__(self, obj): |
| 48 | return self.__unicode__().encode('utf-8') |
| 49 | _python_2_unicode_compatible_str = _STR() |
| 50 | |
46 | 51 | def python_2_unicode_compatible(klass): |
47 | 52 | """ |
48 | 53 | A decorator that defines __unicode__ and __str__ methods under Python 2. |
… |
… |
def python_2_unicode_compatible(klass):
|
56 | 61 | raise ValueError("@python_2_unicode_compatible cannot be applied " |
57 | 62 | "to %s because it doesn't define __str__()." % |
58 | 63 | klass.__name__) |
| 64 | # this was already applied once |
| 65 | if klass.__str__ == _python_2_unicode_compatible_str: |
| 66 | return klass |
59 | 67 | klass.__unicode__ = klass.__str__ |
60 | | klass.__str__ = lambda self: self.__unicode__().encode('utf-8') |
| 68 | klass.__str__ = _python_2_unicode_compatible_str |
61 | 69 | return klass |
62 | 70 | |
63 | 71 | def smart_text(s, encoding='utf-8', strings_only=False, errors='strict'): |