msg76260 - (view) |
Author: Dwayne Bailey (dwayne) |
Date: 2008-11-22 21:44 |
The following code in optparse:
if len(rargs) < nargs:
if nargs == 1:
self.error(_("%s option requires an argument") % opt)
else:
self.error(_("%s option requires %d arguments")
% (opt, nargs))
works for languages with plurals of n!=1 but will not work for many
others that have more sophisticated plurals.
I've created a patch that handles missing gettext and implements it
correctly if it is available. Be aware that I have not been able to test
the patch.
|
msg76261 - (view) |
Author: David W. Lambert (LambertDW) |
Date: 2008-11-22 21:54 |
And while at it, replace "usage" with "Use".
"Usage" isn't a word.
|
msg76262 - (view) |
Author: Dwayne Bailey (dwayne) |
Date: 2008-11-22 22:10 |
Mmm some problems with my head late at night. This patch sorts things
out and makes sure strings can be extracted by xgettext
|
msg107561 - (view) |
Author: Éric Araujo (eric.araujo) * |
Date: 2010-06-11 17:02 |
Thanks for your patch. I have some remarks:
1) please produce a patch from the top level of a Python checkout (cf. http://www.python.org/dev/patches/);
2) wrap lines under 80 characters;
3) bug with %-formatting: the singular message takes one arg, the plural two (optparse bug, not your patch’s bug, but the patch should fix it too);
4) “usage” has been used for decades in command line parsing, it’s fine.
I’m adding Armin to the nosy list since he’s listed in py3k/Misc/maintainers.rst
|
msg120530 - (view) |
Author: Éric Araujo (eric.araujo) * |
Date: 2010-11-05 20:28 |
Now that argparse has been included in the standard library to supersede optparse, I’m not sure there is still value in fixing this bug.
|
msg121539 - (view) |
Author: Éric Araujo (eric.araujo) * |
Date: 2010-11-19 15:36 |
optparse is widely used, so the answer to my question is: yes, it is worth fixing. Checking argparse for the same errors is also a good idea.
Dwayne: can you update your patch to address my remarks? If not, someone else or I may do it. Adding the “easy” keyword for potential bug-day contributors.
|
msg123286 - (view) |
Author: Éric Araujo (eric.araujo) * |
Date: 2010-12-03 19:47 |
I just checked argparse and there are similar non-optimal calls. Not all languages can use “string(s)” to express with 0, 1 or more, that’s why we have ngettext.
Georg: This is a string change similar to #10528. Does it need a patch and review before the beta1 too?
|
msg123373 - (view) |
Author: Éric Araujo (eric.araujo) * |
Date: 2010-12-04 17:22 |
Attached patch fixes the two misuses I found in argparse.
I tried importing ngettext as _ngettext to comply with arpgarse’s crazy^Wpersonal <wink> import style (enforced in TestImportStar), but then I could not force xgettext to find all the strings. Rather than struggle longer with the program, I chose to add an exception for ngettext in the test. “from argparse import *” does not import ngettext, thanks to __all__, so I think my choice is simple and sensible.
|
msg123375 - (view) |
Author: Éric Araujo (eric.araujo) * |
Date: 2010-12-04 17:26 |
Georg approved my patch for the beta1. Steven, since you approved my other gettext-related changes, we thing it’s okay if I don’t wait for your +1.
For optparse, I will review the changes later.
|
msg123377 - (view) |
Author: Éric Araujo (eric.araujo) * |
Date: 2010-12-04 17:32 |
Revision 87056
|
msg123418 - (view) |
Author: Steven Bethard (bethard) * |
Date: 2010-12-05 10:25 |
The workaround in TestImportStar is fine. The test is really just meant to make sure that __all__ contains all the current API methods, and the "_" checks were the easiest way at the time to check that.
|
msg124576 - (view) |
Author: Éric Araujo (eric.araujo) * |
Date: 2010-12-23 23:29 |
Updated patch for optparse. Georg: Is this okay for 3.2?
Based on Steven’s decision for another patch that changed strings, these fixes won’t be backported.
|
msg124644 - (view) |
Author: Éric Araujo (eric.araujo) * |
Date: 2010-12-25 18:47 |
Previous version was incomplete.
|
msg127755 - (view) |
Author: Éric Araujo (eric.araujo) * |
Date: 2011-02-02 19:56 |
Looks like this will have to wait for 3.3, unfortunately.
|
msg131526 - (view) |
Author: Roundup Robot (python-dev) |
Date: 2011-03-20 19:06 |
New changeset 4a5782a2b074 by Éric Araujo in branch 'default':
Use proper gettext plural forms in optparse (closes #4391).
http://hg.python.org/cpython/rev/4a5782a2b074
|
|
Date |
User |
Action |
Args |
2022-04-11 14:56:41 | admin | set | github: 48641 |
2011-03-20 19:06:48 | python-dev | set | status: open -> closed
nosy:
+ python-dev messages:
+ msg131526
resolution: fixed stage: patch review -> resolved |
2011-02-02 19:56:34 | eric.araujo | set | versions:
+ Python 3.3, - Python 3.2 nosy:
gward, georg.brandl, bethard, LambertDW, aronacher, eric.araujo, dwayne messages:
+ msg127755
keywords:
+ needs review stage: patch review |
2010-12-25 18:47:38 | eric.araujo | set | files:
+ fix-optparse-ngettext.diff nosy:
+ gward messages:
+ msg124644
|
2010-12-25 18:44:54 | eric.araujo | set | files:
- fix-optparse-ngettext.diff nosy:
georg.brandl, bethard, LambertDW, aronacher, eric.araujo, dwayne |
2010-12-23 23:59:22 | eric.araujo | link | issue10766 dependencies |
2010-12-23 23:29:47 | eric.araujo | set | files:
+ fix-optparse-ngettext.diff
versions:
- Python 3.1, Python 2.7 messages:
+ msg124576 nosy:
georg.brandl, bethard, LambertDW, aronacher, eric.araujo, dwayne |
2010-12-12 17:05:15 | r.david.murray | set | priority: normal |
2010-12-05 10:25:45 | bethard | set | messages:
+ msg123418 |
2010-12-04 17:32:56 | eric.araujo | set | messages:
+ msg123377 |
2010-12-04 17:26:15 | eric.araujo | set | assignee: eric.araujo messages:
+ msg123375 |
2010-12-04 17:22:16 | eric.araujo | set | files:
+ fix-argparse-ngettext.diff
messages:
+ msg123373 title: optparse: use proper gettext plurals forms -> use proper gettext plurals forms in argparse and optparse |
2010-12-03 19:47:26 | eric.araujo | set | priority: low -> (no value) nosy:
+ georg.brandl, bethard messages:
+ msg123286
|
2010-11-19 15:36:22 | eric.araujo | set | keywords:
+ easy
messages:
+ msg121539 |
2010-11-05 20:28:39 | eric.araujo | set | messages:
+ msg120530 |
2010-08-04 23:52:35 | terry.reedy | set | versions:
+ Python 3.1, Python 2.7, Python 3.2, - Python 2.5 |
2010-06-11 17:02:21 | eric.araujo | set | nosy:
+ aronacher, eric.araujo messages:
+ msg107561
|
2008-11-23 20:21:07 | rhettinger | set | priority: low |
2008-11-22 22:10:25 | dwayne | set | files:
+ optparse_proper_gettext_plurals.diff messages:
+ msg76262 |
2008-11-22 21:54:19 | LambertDW | set | nosy:
+ LambertDW messages:
+ msg76261 |
2008-11-22 21:44:27 | dwayne | create | |