[issue12193] Argparse does not work together with gettext and non-ASCII help text

Thorsten Kampe report at bugs.python.org
Fri May 27 00:53:40 CEST 2011


New submission from Thorsten Kampe <thorsten at thorstenkampe.de>:

Error with argparse and UTF-8 non-ASCII help text on Linux (works on Windows and on Linux with optparse):

% LANG=de_De ./script.py --help
Traceback (most recent call last):
  File "./script.py", line 26, in <module>
    args = cmdlineparser.parse_args()
  File "/usr/lib/python2.7/argparse.py", line 1678, in parse_args
    args, argv = self.parse_known_args(args, namespace)
  File "/usr/lib/python2.7/argparse.py", line 1710, in parse_known_args
    namespace, args = self._parse_known_args(args, namespace)
  File "/usr/lib/python2.7/argparse.py", line 1916, in _parse_known_args
    start_index = consume_optional(start_index)
  File "/usr/lib/python2.7/argparse.py", line 1856, in consume_optional
    take_action(action, args, option_string)
  File "/usr/lib/python2.7/argparse.py", line 1784, in take_action
    action(self, namespace, argument_values, option_string)
  File "/usr/lib/python2.7/argparse.py", line 993, in __call__
    parser.print_help()
  File "/usr/lib/python2.7/argparse.py", line 2303, in print_help
    self._print_message(self.format_help(), file)
  File "/usr/lib/python2.7/argparse.py", line 2317, in _print_message
    file.write(message)
UnicodeEncodeError: 'ascii' codec can't encode character u'\xdc' in position 91: ordinal not in range(128)

----------
components: Unicode
files: script.py
messages: 137013
nosy: thorsten
priority: normal
severity: normal
status: open
title: Argparse does not work together with gettext and non-ASCII help text
versions: Python 2.7
Added file: http://bugs.python.org/file22138/script.py

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


More information about the Python-bugs-list mailing list