summaryrefslogtreecommitdiff
path: root/django/utils/functional.py
diff options
context:
space:
mode:
authorAymeric Augustin <aymeric.augustin@m4x.org>2012-07-20 14:48:51 +0200
committerAymeric Augustin <aymeric.augustin@m4x.org>2012-07-22 09:29:54 +0200
commitbdca5ea345c548a82a80d198906818c9ccbef896 (patch)
tree5c3f5fe5ad2522175d67b96a1fce1ff1763ba125 /django/utils/functional.py
parent3cb2457f46b3e40ff6b6acffcb3fd44cbea091e5 (diff)
[py3] Replaced unicode/str by six.text_type/bytes.
Diffstat (limited to 'django/utils/functional.py')
-rw-r--r--django/utils/functional.py11
1 files changed, 6 insertions, 5 deletions
diff --git a/django/utils/functional.py b/django/utils/functional.py
index 31466ee8b8..2dca182b99 100644
--- a/django/utils/functional.py
+++ b/django/utils/functional.py
@@ -3,6 +3,7 @@ import operator
from functools import wraps, update_wrapper
import sys
+from django.utils import six
# You can't trivially replace this `functools.partial` because this binds to
# classes and returns bound instances, whereas functools.partial (on CPython)
@@ -92,8 +93,8 @@ def lazy(func, *resultclasses):
if hasattr(cls, k):
continue
setattr(cls, k, meth)
- cls._delegate_str = str in resultclasses
- cls._delegate_unicode = unicode in resultclasses
+ cls._delegate_str = bytes in resultclasses
+ cls._delegate_unicode = six.text_type in resultclasses
assert not (cls._delegate_str and cls._delegate_unicode), "Cannot call lazy() with both str and unicode return types."
if cls._delegate_unicode:
cls.__unicode__ = cls.__unicode_cast
@@ -147,7 +148,7 @@ def lazy(func, *resultclasses):
if self._delegate_str:
return str(self) % rhs
elif self._delegate_unicode:
- return unicode(self) % rhs
+ return six.text_type(self) % rhs
else:
raise AssertionError('__mod__ not supported for non-string types')
@@ -255,8 +256,8 @@ class SimpleLazyObject(LazyObject):
def _setup(self):
self._wrapped = self._setupfunc()
- __str__ = new_method_proxy(str)
- __unicode__ = new_method_proxy(unicode)
+ __str__ = new_method_proxy(bytes)
+ __unicode__ = new_method_proxy(six.text_type)
def __deepcopy__(self, memo):
if self._wrapped is empty: