As you can see:
- City inherits from Base abstract model,
- City is decorated by @python_2_unicode_compatible,
- Base is also decorated by @python_2_unicode_compatible,
- Base defines __str__
- City does not define __str__
When these conditions are met then Django 1.5 gets stuck in an infinite
loop. The solution is to remove @python_2_unicode_compatible decorator
from City.
Traceback: https://travis-ci.org/yourlabs/django-autocomplete-
light/jobs/11953680
I don't know if this a lack of documentation or a bug.
--
Ticket URL: <https://code.djangoproject.com/ticket/21198>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* needs_better_patch: => 0
* component: Uncategorized => Utilities
* needs_tests: => 0
* needs_docs: => 0
* type: Uncategorized => Bug
* stage: Unreviewed => Accepted
Comment:
The documentation makes it clear that `@python_2_unicode_compatible` is
only intended for classes that have a `__str__` method.
https://docs.djangoproject.com/en/dev/ref/utils/#django.utils.encoding.python_2_unicode_compatible
Django's historical behavior of building `__str__` from `__unicode__` and
backwards-compatibility concerns make `@python_2_unicode_compatible` prone
to infinite recursion.
This is extremely hard to debug. It's impossible to print the object since
`unicode`, `str` and `repr` all go into infinite recursion. I'd like to
raise a better exception instead.
--
Ticket URL: <https://code.djangoproject.com/ticket/21198#comment:1>
Comment (by jpic):
Thanks for the link, but I don't get why that would work on Django 1.4.2
and not on Django 1.5.4.
--
Ticket URL: <https://code.djangoproject.com/ticket/21198#comment:2>
* owner: nobody => chmodas
* status: new => assigned
Comment:
PR - https://github.com/django/django/pull/1703
--
Ticket URL: <https://code.djangoproject.com/ticket/21198#comment:3>
* owner: chmodas => aaugustin
--
Ticket URL: <https://code.djangoproject.com/ticket/21198#comment:4>
Comment (by aaugustin):
#19362 was an earlier attempt at fixing this problem. The approach
suggested here is more robust.
--
Ticket URL: <https://code.djangoproject.com/ticket/21198#comment:5>
* status: assigned => closed
* resolution: => fixed
Comment:
In [changeset:"f0c7649b1692f8441eb9b9b923b2bed8e95f9185"]:
{{{
#!CommitTicketReference repository=""
revision="f0c7649b1692f8441eb9b9b923b2bed8e95f9185"
Fixed #21198 -- Prevented invalid use of @python_2_unicode_compatible.
Thanks jpic for the report and chmodas for working on a patch.
Reverts 2ea80b94. Refs #19362.
Conflicts:
tests/utils_tests/test_encoding.py
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/21198#comment:6>
Comment (by Aymeric Augustin <aymeric.augustin@…>):
In [changeset:"589dc49e129f63801c54c15e408c944a345b3dfe"]:
{{{
#!CommitTicketReference repository=""
revision="589dc49e129f63801c54c15e408c944a345b3dfe"
Fixed #21198 -- Prevented invalid use of @python_2_unicode_compatible.
Thanks jpic for the report and chmodas for working on a patch.
Reverts 2ea80b94. Refs #19362.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/21198#comment:7>