From bdca5ea345c548a82a80d198906818c9ccbef896 Mon Sep 17 00:00:00 2001 From: Aymeric Augustin Date: Fri, 20 Jul 2012 14:48:51 +0200 Subject: [py3] Replaced unicode/str by six.text_type/bytes. --- django/utils/functional.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'django/utils/functional.py') 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: -- cgit v1.3