Filip Gruszczyński grusz...@gmail.com added the comment:
Here is a small patch. Could you advise me, how can I test it now? Or is it an
issue, that doesn't require writing new tests?
--
keywords: +patch
Added file: http://bugs.python.org/file20970/8841.patch
Filip Gruszczyński grusz...@gmail.com added the comment:
I'd be happy to provide a patch.
How about extending getopt api to something like this:
optlist, args = getopt.getopt(['-b'], 'e', not_recognized=no %s option,
mate!)
GetoptError: no -b option, mate!
Or maybe you should provide a
Filip Gruszczyński grusz...@gmail.com added the comment:
One more solution. Maybe getopt should expose variables that hold error
messages (rather than have them hardcoded in the code), that can be simply
substituted by the user before he runs getopt? But I don't really like this one.
Éric Araujo mer...@netwok.org added the comment:
Filip: The standard way of doing localization is thanks to the gettext module.
Richard: Regarding the contents of the error messages, please make specific
remarks on what is lacking.
--
stage: - needs patch
versions: +Python 3.3
Filip Gruszczyński grusz...@gmail.com added the comment:
I understand I should do something similar to what is done in argparse:
from gettext import gettext as _, ngettext
...
message = ngettext('conflicting option string: %s',
'conflicting option strings: %s',
Richard Lowe richl...@richlowe.net added the comment:
I don't find anything lacking about the error messages, I meant that there were
no more specific exceptions, or fields in GetoptError to allow the caller to
tell what was specifically wrong and provide its own localized messages. So
while
Éric Araujo mer...@netwok.org added the comment:
Richard: It’s not common to use subclasses to allow message customization.
Would gettext cover your need?
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue8841
Richard Lowe richl...@richlowe.net added the comment:
Sure, just localizing them in the getopt implementation would be fine.
I suggested subclassing to solve the more general problem of the caller being
able to tell one getopt error from another, for which it is a pretty common
solution.
Éric Araujo mer...@netwok.org added the comment:
Do you want to provide a patch?
--
nosy: +eric.araujo
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue8841
___
Changes by Terry J. Reedy tjre...@udel.edu:
--
versions: +Python 3.2 -Python 2.6
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue8841
___
___
New submission from Richard Lowe richl...@richlowe.net:
The GetoptError exception raised by getopt.getopt() to indicate errors in
provided arguments seems intended to be displayed to the user[1], but is not
localized and doesn't contain enough information, short of interpreting the
error
11 matches
Mail list logo