[issue2931] optparse: various problems with unicode and gettext

Ivan Vilata i Balaguer report at bugs.python.org
Wed Jun 18 10:13:51 CEST 2008


Ivan Vilata i Balaguer <ivilata at users.sourceforge.net> added the comment:

What I find most bothersome is that ``optparse`` is being inconsistent
in the types of localised strings it expects. It needs Unicode strings
for snippets forming part of the help message, while it expects normal
strings in other places like ``OptionParser.error()`` --a fact which
isn't documented at all, BTW.

I've been developing a medium app lately with localised messages all
over the place using several packages in the standard library and
``optarparse``'s help messages are the only place where Unicode strings
have been required. I'm not saying that ``optparse`` shouldn't use
Unicode, but it'd be nice if it was consistent and the fact was documented.

I'm attaching a tiny script which uses ``optparse``.  Just try to change
any appearance of the ``s`` normal string to Unicode ``us`` or
vice-versa, then call the program with ``--help`` or no arguments (it
requires one) and you get a ``UnicodeError``. Thanks!

----------
nosy: +ivilata
Added file: http://bugs.python.org/file10649/optparse_unicode.py

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


More information about the Python-bugs-list mailing list