Jeez, Barry, that itty-bitty change you made last night to not import _ into the namespace by default broke a *lot* of things...
I was trying to use config_list, and had to edit several modules to do a from Mailman.i18n import _... Digester.py Archiver.py GatewayManager.py MailList.py
(Of course, just my luck, MailList.py blows up the same place the admin page blows up on a bad list, line 362 in GetConfigInfo, with the same "ValueError: list.index(x): x not in list" error...)
I expect there's more places that need to do the import, Those are just the first few.
Oh, and something about the HTMLFormatter change last night broke newlang, I haven't had a chance to look at that since 4am.
On Fri, Feb 16, 2001 at 04:15:45PM -0500, Ron Jarrell wrote:
Jeez, Barry, that itty-bitty change you made last night to not import _ into the namespace by default broke a *lot* of things...
I was trying to use config_list, and had to edit several modules to do a from Mailman.i18n import _... Digester.py Archiver.py GatewayManager.py MailList.py
A quick grep through a fresh tree gives me this handy (for Barry and for those that run pre-alpha Mailmans on production machines :-) list:
+./Mailman/Archiver/Archiver.py +./Mailman/Archiver/pipermail.py +./Mailman/Bouncer.py +./Mailman/Deliverer.py +./Mailman/Digester.py +./Mailman/Errors.py +./Mailman/GatewayManager.py +./Mailman/ListAdmin.py +./Mailman/MailCommandHandler.py +./Mailman/MailList.py +./Mailman/htmlformat.py +./Mailman/Cgi/admin.py +./Mailman/Cgi/admindb.py +./Mailman/Cgi/edithtml.py +./Mailman/Cgi/handle_opts.py +./Mailman/Cgi/listinfo.py +./Mailman/Cgi/options.py +./Mailman/Cgi/private.py +./Mailman/Cgi/roster.py +./Mailman/Cgi/subscribe.py +./Mailman/Handlers/Acknowledge.py
(That's done using: find . -type f -print | xargs grep -l '[^_a-zA-Z0-9]_(' > list find . -type f -print | xargs fgrep -l 'import _' | diff -u - list | fgrep + and ignoring the .gz files.)
It's probably safe to assume that anything that imports gettext needs to be modified to import _ explicitly, but I'll let Barry draw that conclusion :-)
-- Thomas Wouters <thomas@xs4all.net>
Hi! I'm a .signature virus! copy me into your .signature file to help me spread!
At 11:00 PM 2/16/01 +0100, Thomas Wouters wrote:
A quick grep through a fresh tree gives me this handy (for Barry and for those that run pre-alpha Mailmans on production machines :-) list:
Ok, I went in and put in the appropriate import in all those modules except pipermail, which has it's own internal definition of _, and one other which was importing all of the i18n module anyway.
Barry, just in case you haven't done it, and it helps you, I uploaded a patch to 103852, which is a diff against my current snapshot; it's all the imports, plus the typo in newlang.
On Fri, Feb 16, 2001 at 09:19:00PM -0500, Ron Jarrell wrote:
At 11:00 PM 2/16/01 +0100, Thomas Wouters wrote:
A quick grep through a fresh tree gives me this handy (for Barry and for those that run pre-alpha Mailmans on production machines :-) list:
Ok, I went in and put in the appropriate import in all those modules except pipermail, which has it's own internal definition of _, and one other which was importing all of the i18n module anyway.
Note that that isn't enough. 'from module import *' doesn't import names starting with a _, and _ does start with a _. I can't find which module you're talking about, though, so maybe you mean that it does 'from module import spam, parrot, ham, creosote, voom, _, bucket', which would work.
-- Thomas Wouters <thomas@xs4all.net>
Hi! I'm a .signature virus! copy me into your .signature file to help me spread!
At 11:26 AM 2/17/01 +0100, you wrote:
On Fri, Feb 16, 2001 at 09:19:00PM -0500, Ron Jarrell wrote:
At 11:00 PM 2/16/01 +0100, Thomas Wouters wrote:
A quick grep through a fresh tree gives me this handy (for Barry and for those that run pre-alpha Mailmans on production machines :-) list:
Ok, I went in and put in the appropriate import in all those modules except pipermail, which has it's own internal definition of _, and one other which was importing all of the i18n module anyway.
Note that that isn't enough. 'from module import *' doesn't import names starting with a _, and _ does start with a _. I can't find which module you're talking about, though, so maybe you mean that it does 'from module import spam, parrot, ham, creosote, voom, _, bucket', which would work.
Errors.py just says "import Mailman.i18n" So that means it's not importing _? Can it use it explicitly? Because what it does is a "rejection=Mailman.i18n._('text')"
On Mon, Feb 19, 2001 at 03:51:46PM -0500, Ron Jarrell wrote:
Ok, I went in and put in the appropriate import in all those modules except pipermail, which has it's own internal definition of _, and one other which was importing all of the i18n module anyway.
Note that that isn't enough. 'from module import *' doesn't import names starting with a _, and _ does start with a _. I can't find which module you're talking about, though, so maybe you mean that it does 'from module import spam, parrot, ham, creosote, voom, _, bucket', which would work.
Errors.py just says "import Mailman.i18n" So that means it's not importing _? Can it use it explicitly? Because what it does is a "rejection=Mailman.i18n._('text')"
Yes, that works, too.
-- Thomas Wouters <thomas@xs4all.net>
Hi! I'm a .signature virus! copy me into your .signature file to help me spread!
Ron Jarrell <jarrell@vt.edu> said:
At 11:26 AM 2/17/01 +0100, you wrote:
On Fri, Feb 16, 2001 at 09:19:00PM -0500, Ron Jarrell wrote:
At 11:00 PM 2/16/01 +0100, Thomas Wouters wrote:
A quick grep through a fresh tree gives me this handy (for Barry and for those that run pre-alpha Mailmans on production machines :-) list:
Ok, I went in and put in the appropriate import in all those modules except pipermail, which has it's own internal definition of _, and one other which was importing all of the i18n module anyway.
Note that that isn't enough. 'from module import *' doesn't import names starting with a _, and _ does start with a _. I can't find which module you're talking about, though, so maybe you mean that it does 'from module import spam, parrot, ham, creosote, voom, _, bucket', which would work.
Errors.py just says "import Mailman.i18n" So that means it's not importing _? Can it use it explicitly? Because what it does is a "rejection=Mailman.i18n._('text')"
Not a problem. The _ restriction only applies to
from module import *
since that form brings in everything from the module into the /current/ namespace. Using
import module
there's no namespace pollution, so no need to restrict what's brought in.
Mats
"RJ" == Ron Jarrell <jarrell@vt.edu> writes:
RJ> Barry, just in case you haven't done it, and it helps you, I
RJ> uploaded a patch to 103852, which is a diff against my current
RJ> snapshot; it's all the imports, plus the typo in newlang.
Thanks, that does help!
"RJ" == Ron Jarrell <jarrell@vt.edu> writes:
RJ> Jeez, Barry, that itty-bitty change you made last night to not
RJ> import _ into the namespace by default broke a *lot* of
RJ> things...
I did that on purpose! :) Explicit is better than implicit.
"TW" == Thomas Wouters <thomas@xs4all.net> writes:
TW> It's probably safe to assume that anything that imports
TW> gettext needs to be modified to import _ explicitly, but I'll
TW> let Barry draw that conclusion :-)
Actually, Mailman.i18n._() tries to improve on gettext._ by adding the new sys._getframe() hack to make the marked strings more succinct. In other words, where you'd have to write (using gettext as _):
_('The list %(listname)s has %(membercnt)s non-digest members' %
{'listname' : mlist.real_name(),
'membercnt': count_of_non_digest_members(mlist),
})
You can now write:
listname = mlist.real_name()
membercnt = count_of_non_digest_members(mlist)
_('The list %(listname)s has %(membercnt)s non-digest members')
You have to use string-dict interpolation because the order of words may be different in different languages. But it seems ridiculous to have to write the varnames twice as in the first example (the second looks worse than it is in practice, because usually the variables you want to interpolate into the string are already present as local variables or arguments).
Most modules therefore will "from Mailman.i18n import _" but Errors.py skips the from...import style to avoid circular imports.
BTW, thanks for the patch Ron. I've just applied it and will now review it, but checking in the changes may have to wait. Seems SF is refusing my ssh pubkey at the moment.
-Barry
participants (4)
-
barry@digicool.com
-
mats@laplaza.org
-
Ron Jarrell
-
Thomas Wouters