diff options
| author | Claude Paroz <claude@2xlibre.net> | 2016-12-01 11:38:01 +0100 |
|---|---|---|
| committer | Claude Paroz <claude@2xlibre.net> | 2017-01-18 16:21:28 +0100 |
| commit | c716fe87821df00f9f03ecc761c914d1682591a2 (patch) | |
| tree | 0436706cdb190acbc76fb5fcf6d66f16e09fafa3 /django/utils/functional.py | |
| parent | e63d98b7beb16d1410168a2315cbe04c43c9c80d (diff) | |
Refs #23919 -- Removed six.PY2/PY3 usage
Thanks Tim Graham for the review.
Diffstat (limited to 'django/utils/functional.py')
| -rw-r--r-- | django/utils/functional.py | 26 |
1 files changed, 6 insertions, 20 deletions
diff --git a/django/utils/functional.py b/django/utils/functional.py index 794f31047c..933085391d 100644 --- a/django/utils/functional.py +++ b/django/utils/functional.py @@ -92,16 +92,9 @@ def lazy(func, *resultclasses): assert not (cls._delegate_bytes and cls._delegate_text), ( "Cannot call lazy() with both bytes and text return types.") if cls._delegate_text: - if six.PY3: - cls.__str__ = cls.__text_cast - else: - cls.__unicode__ = cls.__text_cast - cls.__str__ = cls.__bytes_cast_encoded + cls.__str__ = cls.__text_cast elif cls._delegate_bytes: - if six.PY3: - cls.__bytes__ = cls.__bytes_cast - else: - cls.__str__ = cls.__bytes_cast + cls.__bytes__ = cls.__bytes_cast @classmethod def __promise__(cls, method_name): @@ -154,9 +147,7 @@ def lazy(func, *resultclasses): return hash(self.__cast()) def __mod__(self, rhs): - if self._delegate_bytes and six.PY2: - return bytes(self) % rhs - elif self._delegate_text: + if self._delegate_text: return six.text_type(self) % rhs return self.__cast() % rhs @@ -316,14 +307,9 @@ class LazyObject(object): return result return copy.deepcopy(self._wrapped, memo) - if six.PY3: - __bytes__ = new_method_proxy(bytes) - __str__ = new_method_proxy(str) - __bool__ = new_method_proxy(bool) - else: - __str__ = new_method_proxy(str) - __unicode__ = new_method_proxy(unicode) # NOQA: unicode undefined on PY3 - __nonzero__ = new_method_proxy(bool) + __bytes__ = new_method_proxy(bytes) + __str__ = new_method_proxy(str) + __bool__ = new_method_proxy(bool) # Introspection support __dir__ = new_method_proxy(dir) |
