﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
4803	Don't return translations in __str__ methods	smurf@…	Malcolm Tredinnick	"I just saw a rather lengthy chain of errors which ended in a totally untraceable

{{{
[Sun Jul 08 15:43:03 2007] [error] [client 192.109.102.35] FastCGI: server ""/daten/web/smurf.noris.de/sweb/smurf.fcg"" stderr:     new_obj = func(obj, *arg_vals)
[Sun Jul 08 15:43:03 2007] [error] [client 192.109.102.35] FastCGI: server ""/daten/web/smurf.noris.de/sweb/smurf.fcg"" stderr:   File ""/usr/lib/python2.5/site-packages/django/template/defaultfilters.py"", line 38, in _dec
[Sun Jul 08 15:43:03 2007] [error] [client 192.109.102.35] FastCGI: server ""/daten/web/smurf.noris.de/sweb/smurf.fcg"" stderr:     args[0] = smart_string(args[0])
[Sun Jul 08 15:43:03 2007] [error] [client 192.109.102.35] FastCGI: server ""/daten/web/smurf.noris.de/sweb/smurf.fcg"" stderr:   File""/usr/lib/python2.5/site-packages/django/template/defaultfilters.py"", line 27, in smart_string
[Sun Jul 08 15:43:03 2007] [error] [client 192.109.102.35] FastCGI: server ""/daten/web/smurf.noris.de/sweb/smurf.fcg"" stderr:     obj = str(obj)
[Sun Jul 08 15:43:03 2007] [error] [client 192.109.102.35] FastCGI: server ""/daten/web/smurf.noris.de/sweb/smurf.fcg"" stderr: TypeError: __str__ returned non-string (type instance)
}}}

The problem was fixed by this change:

{{{
diff --git a/django/contrib/auth/models.py b/django/contrib/auth/models.py
index e8384ba..5de8927 100644
--- a/django/contrib/auth/models.py
+++ b/django/contrib/auth/models.py
@@ -282,7 +282,7 @@ class AnonymousUser(object):
         pass
 
     def __str__(self):
-        return _('AnonymousUser')
+        return 'AnonymousUser'
 
     def __eq__(self, other):
         return isinstance(other, self.__class__)

}}}

I don't think __str__ methods should be allowed to return translations (or be allowed to fail, for that matter -- much like __repr__).
"		closed	Internationalization	dev		invalid			Unreviewed	1	0	0	0	0	0
