Issue 12193: Argparse does not work together with gettext and non-ASCII help text (original) (raw)

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