Loading django/utils/encoding.py +0 −24 Original line number Diff line number Diff line Loading @@ -8,7 +8,6 @@ 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 Loading @@ -23,29 +22,6 @@ class DjangoUnicodeDecodeError(UnicodeDecodeError): return '%s. You passed in %r (%s)' % (original, self.obj, type(self.obj)) class StrAndUnicode(object): """ A class that derives __str__ from __unicode__. On Python 2, __str__ returns the output of __unicode__ encoded as a UTF-8 bytestring. On Python 3, __str__ returns the output of __unicode__. 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.", DeprecationWarning, stacklevel=2) super(StrAndUnicode, self).__init__(*args, **kwargs) if six.PY3: def __str__(self): return self.__unicode__() else: def __str__(self): return self.__unicode__().encode('utf-8') def python_2_unicode_compatible(klass): """ A decorator that defines __unicode__ and __str__ methods under Python 2. Loading docs/ref/utils.txt +1 −12 Original line number Diff line number Diff line Loading @@ -188,18 +188,7 @@ The functions defined in this module share the following properties: ========================= .. module:: django.utils.encoding :synopsis: A series of helper classes and function to manage character encoding. .. class:: StrAndUnicode A class that derives ``__str__`` from ``__unicode__``. On Python 2, ``__str__`` returns the output of ``__unicode__`` encoded as a UTF-8 bytestring. On Python 3, ``__str__`` returns the output of ``__unicode__``. 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__``. :synopsis: A series of helper function to manage character encoding. .. function:: python_2_unicode_compatible Loading docs/releases/1.5-alpha-1.txt +1 −1 Original line number Diff line number Diff line Loading @@ -615,7 +615,7 @@ explicitly. ``django.utils.encoding.StrAndUnicode`` ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The :class:`~django.utils.encoding.StrAndUnicode` mix-in has been deprecated. The ``django.utils.encoding.StrAndUnicode`` mix-in has been deprecated. Define a ``__str__`` method and apply the :func:`~django.utils.encoding.python_2_unicode_compatible` decorator instead. Loading docs/releases/1.5-beta-1.txt +1 −1 Original line number Diff line number Diff line Loading @@ -668,7 +668,7 @@ If you rely on features added to :mod:`simplejson` after it became Python's ``django.utils.encoding.StrAndUnicode`` ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The :class:`~django.utils.encoding.StrAndUnicode` mix-in has been deprecated. The ``django.utils.encoding.StrAndUnicode`` mix-in has been deprecated. Define a ``__str__`` method and apply the :func:`~django.utils.encoding.python_2_unicode_compatible` decorator instead. Loading docs/releases/1.5.txt +1 −1 Original line number Diff line number Diff line Loading @@ -775,7 +775,7 @@ If you rely on features added to :mod:`simplejson` after it became Python's ``django.utils.encoding.StrAndUnicode`` ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The :class:`~django.utils.encoding.StrAndUnicode` mix-in has been deprecated. The ``django.utils.encoding.StrAndUnicode`` mix-in has been deprecated. Define a ``__str__`` method and apply the :func:`~django.utils.encoding.python_2_unicode_compatible` decorator instead. Loading Loading
django/utils/encoding.py +0 −24 Original line number Diff line number Diff line Loading @@ -8,7 +8,6 @@ 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 Loading @@ -23,29 +22,6 @@ class DjangoUnicodeDecodeError(UnicodeDecodeError): return '%s. You passed in %r (%s)' % (original, self.obj, type(self.obj)) class StrAndUnicode(object): """ A class that derives __str__ from __unicode__. On Python 2, __str__ returns the output of __unicode__ encoded as a UTF-8 bytestring. On Python 3, __str__ returns the output of __unicode__. 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.", DeprecationWarning, stacklevel=2) super(StrAndUnicode, self).__init__(*args, **kwargs) if six.PY3: def __str__(self): return self.__unicode__() else: def __str__(self): return self.__unicode__().encode('utf-8') def python_2_unicode_compatible(klass): """ A decorator that defines __unicode__ and __str__ methods under Python 2. Loading
docs/ref/utils.txt +1 −12 Original line number Diff line number Diff line Loading @@ -188,18 +188,7 @@ The functions defined in this module share the following properties: ========================= .. module:: django.utils.encoding :synopsis: A series of helper classes and function to manage character encoding. .. class:: StrAndUnicode A class that derives ``__str__`` from ``__unicode__``. On Python 2, ``__str__`` returns the output of ``__unicode__`` encoded as a UTF-8 bytestring. On Python 3, ``__str__`` returns the output of ``__unicode__``. 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__``. :synopsis: A series of helper function to manage character encoding. .. function:: python_2_unicode_compatible Loading
docs/releases/1.5-alpha-1.txt +1 −1 Original line number Diff line number Diff line Loading @@ -615,7 +615,7 @@ explicitly. ``django.utils.encoding.StrAndUnicode`` ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The :class:`~django.utils.encoding.StrAndUnicode` mix-in has been deprecated. The ``django.utils.encoding.StrAndUnicode`` mix-in has been deprecated. Define a ``__str__`` method and apply the :func:`~django.utils.encoding.python_2_unicode_compatible` decorator instead. Loading
docs/releases/1.5-beta-1.txt +1 −1 Original line number Diff line number Diff line Loading @@ -668,7 +668,7 @@ If you rely on features added to :mod:`simplejson` after it became Python's ``django.utils.encoding.StrAndUnicode`` ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The :class:`~django.utils.encoding.StrAndUnicode` mix-in has been deprecated. The ``django.utils.encoding.StrAndUnicode`` mix-in has been deprecated. Define a ``__str__`` method and apply the :func:`~django.utils.encoding.python_2_unicode_compatible` decorator instead. Loading
docs/releases/1.5.txt +1 −1 Original line number Diff line number Diff line Loading @@ -775,7 +775,7 @@ If you rely on features added to :mod:`simplejson` after it became Python's ``django.utils.encoding.StrAndUnicode`` ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The :class:`~django.utils.encoding.StrAndUnicode` mix-in has been deprecated. The ``django.utils.encoding.StrAndUnicode`` mix-in has been deprecated. Define a ``__str__`` method and apply the :func:`~django.utils.encoding.python_2_unicode_compatible` decorator instead. Loading