Opened 18 years ago
Closed 18 years ago
#4803 closed (invalid)
Don't return translations in __str__ methods
| Reported by: | Owned by: | Malcolm Tredinnick | |
|---|---|---|---|
| Component: | Internationalization | Version: | dev |
| Severity: | Keywords: | ||
| Cc: | Triage Stage: | Unreviewed | |
| Has patch: | yes | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
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).
Change History (3)
comment:1 by , 18 years ago
comment:2 by , 18 years ago
| Component: | Uncategorized → Internationalization |
|---|---|
| Has patch: | set |
| Owner: | changed from to |
comment:3 by , 18 years ago
| Resolution: | → invalid |
|---|---|
| Status: | new → closed |
This was fixed in trunk in [5590].
Note:
See TracTickets
for help on using tickets.
Stupid wiki-ization. Of course that's
__str__and__repr__, not str and repr.