[issue8841] getopt errors should be specialized

Éric Araujo report at bugs.python.org
Wed Mar 2 11:24:03 CET 2011


Éric Araujo <merwok at netwok.org> added the comment:

> 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.

Now I see what you meant and understand your request.  optparse has five different error classes and argparse has two, but they don’t bubble up to the caller, they’re caught and turned into error messages.  getopt is different, since it require its users to do the gruntwork, so having different exceptions for different user errors would be helpful.  Compatibility would not be an issue, we’d just make all classes inherit from GetoptError so that except clauses would still work.  I think you should take this to the python-ideas mailing list: Do other getopt users need this functionality?  What subclasses should there be?

Filip: Localization of error messages in getopt is another enhancement.  Would you mind opening another report and moving your patch there?  Thanks.

----------
title: GetoptError strings should be localized -> getopt errors should be specialized

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue8841>
_______________________________________


More information about the Python-bugs-list mailing list