bpo-31475: fix argparse to support utf8 by Ali-Razmjoo · Pull Request #3577 · python/cpython (original) (raw)
Regarding #3468 discussion, there is the same bug was in argparse (and optparse) which fixed in this PR.
Python2
parser.print_help()
File "C:\Python27\lib\argparse.py", line 2340, in print_help
self._print_message(self.format_help(), file)
File "C:\Python27\lib\argparse.py", line 2354, in _print_message
file.write(message)
File "C:\Python27\lib\encodings\cp437.py", line 12, in encode
return codecs.charmap_encode(input,errors,encoding_map)
UnicodeEncodeError: 'charmap' codec can't encode characters in position 490-494: character maps to <undefined>
Python3
parser.print_help()
File "C:\Python35\lib\argparse.py", line 2358, in print_help
self._print_message(self.format_help(), file)
File "C:\Python35\lib\argparse.py", line 2364, in _print_message
file.write(message)
File "C:\Python35\lib\encodings\cp437.py", line 19, in encode
return codecs.charmap_encode(input,self.errors,encoding_map)[0]
UnicodeEncodeError: 'charmap' codec can't encode characters in position 498-502: character maps to <undefined>
or let me know if there is a better solution?
Regards.