This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Argparse does not work together with gettext and non-ASCII help text
Type: behavior Stage:
Components: Unicode Versions: Python 2.7
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: bethard, thorsten
Priority: normal Keywords:

Created on 2011-05-26 22:53 by thorsten, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
script.py thorsten, 2011-05-26 22:53 Shows the simple test case - set "clparser" to "optparse" and it works
script.de.po thorsten, 2011-05-26 22:55 Translation file
script.mo thorsten, 2011-05-26 22:55 Compiled translation file
Messages (2)
msg137013 - (view) Author: Thorsten Kampe (thorsten) Date: 2011-05-26 22:53
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)
msg137035 - (view) Author: Thorsten Kampe (thorsten) Date: 2011-05-27 08:18
"LANG=de_De" - should've been "LANG=de_DE". Sorry for wasting someone's time. I shouldn't write bug reports in the middle of the night.

Sorry and thanks, Thorsten
History
Date User Action Args
2022-04-11 14:57:17adminsetgithub: 56402
2011-05-27 08:18:14thorstensetstatus: open -> closed
resolution: not a bug
messages: + msg137035
2011-05-26 23:03:49ezio.melottisetnosy: + bethard
type: crash -> behavior
2011-05-26 22:55:42thorstensetfiles: + script.mo
2011-05-26 22:55:05thorstensetfiles: + script.de.po
2011-05-26 22:54:00thorstensettype: crash
2011-05-26 22:53:40thorstencreate