Do the docs say this should be supported? I’m a die-hard unicode user, but this treads the line between fix and feature, so if the docs don’t restrict help to str, this could be fixed, otherwise we’re out of luck for the 2.x series.
Are you sure this is an argparse issue, and not a terminal issue? Here's what I see: >>> parser = argparse.ArgumentParser(description=u'Rus Рус') >>> print(parser.description) Rus Рус >>> sys.stderr.write(parser.description) Traceback (most recent call last): File "", line 1, in UnicodeEncodeError: 'ascii' codec can't encode characters in position 4-6: ordinal not in range(128) >>> parser.format_help() u'usage: [-h]\n\nRus \u0420\u0443\u0441\n\noptional arguments:\n -h, --help show this help message and exit\n' >>> sys.stderr.write(parser.format_help()) Traceback (most recent call last): File "", line 1, in UnicodeEncodeError: 'ascii' codec can't encode characters in position 17-19: ordinal not in range(128) To me, it looks like sys.stderr doesn't like the unicode, even though at the interactive prompt I can print things okay.
Closing as invalid, as to me this looks like a classic terminal encoding issue and not an argparse issue, and there was no response from the user who filed the issue. If someone still thinks this is an argparse issue, please provide a test and reopen the issue.
This bit me also. For anybody else reading this, argparsenobug.py includes a class that provides a workaround. python argparsebug.py --help works, but: python argparsebug.py --help > python argparsebug.py --help | more give the error. However: python argparsenobug.py --help python argparsenobug.py --help > python argparsenobug.py --help