django.utils.encoding.force_text() should call unicode() instead of __unicode__()
|Reported by:||Owned by:||Florian Apolloner|
|Has patch:||yes||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
Description (last modified by )
unicode() builtin function, the method
__unicode__() does not validate its return type.
If people wrote a buggy
__unicode__ which does not return
unicode, this can lead to a situation where
force_text() will return non-text, and so the bug may only appear much, much later when other parts of the application assumes they were getting text and often it will become very difficult to find how the non-string object came from.
force_text() should be switched to use
unicode() so returning non-text from
__unicode__() will immediately raise an error at the point where the error would have been obvious.
Change History (4)
comment:4 Changed 3 years ago by
|Owner:||changed from nobody to Florian Apolloner|
|Status:||new → assigned|
|Triage Stage:||Unreviewed → Accepted|
|Version:||1.5 → master|