Opened 18 years ago
Closed 17 years ago
#2920 closed defect (fixed)
Putting _() into builtins causes trouble with doctests
Reported by: | Malcolm Tredinnick | Owned by: | nobody |
---|---|---|---|
Component: | Testing framework | Version: | |
Severity: | normal | Keywords: | |
Cc: | Triage Stage: | Accepted | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
We install a function called _()
as an alias for gettext()
into __builtins__
so that we don't have to import everywhere we want to translate strings.
The Python interactive shell uses the _
variable to store the most recent result. Any doctests run in the same sort of environment as the interactive shell and so this variable gets nuked. If a class has doctests and uses translation functionality, chaos ensues.
One solution is to import gettext()
and alias it to _()
in each modules' scope. A little awkward but not inherently bad. Maybe there's another solution I haven't thought of yet, though.
Original problem description in this django-users thread.
Change History (11)
comment:1 by , 18 years ago
comment:2 by , 18 years ago
Triage Stage: | Unreviewed → Design decision needed |
---|
marked #2734 as duplicate
comment:3 by , 18 years ago
follow-up: 6 comment:4 by , 18 years ago
comment:5 by , 18 years ago
comment:6 by , 18 years ago
Replying to mtredinnick:
(In [4486]) Revert [4485] in order to fix accidental mod_python breakage. Refs #2920.
For reference, the problems we were seeing are in this django-users thread. They should be fixed after [4905], so we can move onto part II of this ticket, which is removing _() from builtins.
comment:7 by , 17 years ago
comment:8 by , 17 years ago
Triage Stage: | Design decision needed → Accepted |
---|
comment:10 by , 17 years ago
Resolution: | fixed |
---|---|
Status: | closed → reopened |
No it's not fixed. It's only fixed in Django's core because we work around it. Not fixed for everybody else writing tests.
comment:11 by , 17 years ago
Resolution: | → fixed |
---|---|
Status: | reopened → closed |
Looks like a dupe of #2734.