Author tanbro-liu
Recipients tanbro-liu
Date 2015-05-28.02:20:59
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1432779659.79.0.171307025039.issue24307@psf.upfronthosting.co.za>
In-reply-to
Content
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)
  ++ )
History
Date User Action Args
2015-05-28 02:20:59tanbro-liusetrecipients: + tanbro-liu
2015-05-28 02:20:59tanbro-liusetmessageid: <1432779659.79.0.171307025039.issue24307@psf.upfronthosting.co.za>
2015-05-28 02:20:59tanbro-liulinkissue24307 messages
2015-05-28 02:20:59tanbro-liucreate