[New-bugs-announce] [issue24307] pip error on windows whose current user name contains non-ascii characters
tanbro-liu
report at bugs.python.org
Thu May 28 04:20:59 CEST 2015
New submission from tanbro-liu:
On windows8.1 x64, current user name contains non-ascii characters. When executing ``pip`` in the command-line, such an error happens::
C:\Users\雪彦>pip
Traceback (most recent call last):
File "C:\Python27\lib\runpy.py", line 162, in _run_module_as_main
"__main__", fname, loader, pkg_name)
File "C:\Python27\lib\runpy.py", line 72, in _run_code
exec code in run_globals
File "C:\Python27\Scripts\pip.exe\__main__.py", line 9, in <module>
File "C:\Python27\lib\site-packages\pip\__init__.py", line 210, in main
cmd_name, cmd_args = parseopts(args)
File "C:\Python27\lib\site-packages\pip\__init__.py", line 165, in parseopts
parser.print_help()
File "C:\Python27\lib\optparse.py", line 1676, in print_help
file.write(self.format_help().encode(encoding, "replace"))
File "C:\Python27\lib\optparse.py", line 1656, in format_help
result.append(self.format_option_help(formatter))
File "C:\Python27\lib\optparse.py", line 1639, in format_option_help
result.append(group.format_help(formatter))
File "C:\Python27\lib\optparse.py", line 1120, in format_help
result += OptionContainer.format_help(self, formatter)
File "C:\Python27\lib\optparse.py", line 1091, in format_help
result.append(self.format_option_help(formatter))
File "C:\Python27\lib\optparse.py", line 1080, in format_option_help
result.append(formatter.format_option(option))
File "C:\Python27\lib\optparse.py", line 322, in format_option
help_text = self.expand_default(option)
File "C:\Python27\lib\site-packages\pip\baseparser.py", line 110, in expand_de
fault
return optparse.IndentedHelpFormatter.expand_default(self, option)
File "C:\Python27\lib\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 9-10: ordi
nal not in range(128)
i think, we can modify /lib/optparse.py line 288 to avoid such an error in windows::
-- return option.help.replace(self.default_tag, str(default_value))
++ return option.help.replace(
++ self.default_tag,
++ default_value.encode(sys.getfilesystemencoding())
++ if isinstance(default_value, uicnode)
++ else str(default_value)
++ )
----------
components: Library (Lib)
messages: 244244
nosy: tanbro-liu
priority: normal
severity: normal
status: open
title: pip error on windows whose current user name contains non-ascii characters
type: crash
versions: Python 2.7
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue24307>
_______________________________________
More information about the New-bugs-announce
mailing list