#25218: python_2_unicode_compatible causes infinite recursion when
super().__str__() is called
-------------------------------+--------------------
Reporter: jscn | Owner: nobody
Type: Uncategorized | Status: new
Component: Utilities | Version: 1.8
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------
I have a class `A` which implements `__str__()` and is decorated with
`@python_2_unicode_compatible`.
I have sub-class of `A`, `B`, and `B` 's implementation of `__str__()`
calls `super().__str__()`.
When I call `b.__str__()`, I get the following error: `RuntimeError:
maximum recursion depth exceeded while calling a Python object`.
Partial traceback:
{{{#!python
File "/home/josh/Desktop/temp/djtest/local/lib/python2.7/site-
packages/django/utils/encoding.py", line 42, in <lambda>
klass.__str__ = lambda self: self.__unicode__().encode('utf-8')
File "recursion.py", line 27, in __str__
super().__str__(),
File "/home/josh/Desktop/temp/djtest/local/lib/python2.7/site-
packages/django/utils/encoding.py", line 42, in <lambda>
klass.__str__ = lambda self: self.__unicode__().encode('utf-8')
File "recursion.py", line 27, in __str__
super().__str__(),
}}}
The docs
(https://docs.djangoproject.com/en/dev/ref/utils/#django.utils.encoding.python_2_unicode_compatible)
imply that the decorator should be applied to *any* class implementing
`__str__()`
--
Ticket URL: <https://code.djangoproject.com/ticket/25218>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/047.d7efe90db95acc681b8a1cfdcd9f3047%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.