Sean Wang added the comment:
when an unicode option.default_value could not be ascii encoded, it would throw
exception, detailed logs below:
File "/Users/seanwang/Documents/dev/foo/bar.py", line 119, in main
parser.print_help()
File
"/usr/local/Cellar/python/2.7.10_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/optparse.py",
line 1670, in print_help
file.write(self.format_help().encode(encoding, "replace"))
File
"/usr/local/Cellar/python/2.7.10_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/optparse.py",
line 1650, in format_help
result.append(self.format_option_help(formatter))
File
"/usr/local/Cellar/python/2.7.10_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/optparse.py",
line 1630, in format_option_help
result.append(OptionContainer.format_option_help(self, formatter))
File
"/usr/local/Cellar/python/2.7.10_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/optparse.py",
line 1074, in format_option_help
result.append(formatter.format_option(option))
File
"/usr/local/Cellar/python/2.7.10_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/optparse.py",
line 316, in format_option
help_text = self.expand_default(option)
File
"/usr/local/Cellar/python/2.7.10_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/optparse.py",
line 288, in expand_default
return option.help.replace(self.default_tag, str(default_value))
UnicodeEncodeError: 'ascii' codec can't encode characters in position 3-4:
ordinal not in range(128)
----------
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue2931>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com