pypa/virtualenv — Issue #186: Path prefix is decoded in wrong encoding
Author: gthb
Created: 2011-11-22 15:06:27+00:00
State: open

Creating a virtualenv under a root path containing non-ASCII characters fails if the platform's default encoding differs from its filesystem encoding (`sys.getdefaultencoding() != sys.getfilesystemencoding()`).

As an example, my Mac OS X Lion setup has filesystem encoding `utf-8`, default encoding `ascii`. Sure enough, this:

mkdir ~/Ættartal
cd ~/Ættartal
virtualenv FOO

(where that path has the byte representation `'/Users/gthb/quickies/\xc3\x86ttartal/'`) fails thus:

```
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/Current/bin/virtualenv", line 8, in
load_entry_point('virtualenv==1.6.4', 'console_scripts', 'virtualenv')()
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/virtualenv.py", line 810, in main
never_download=options.never_download)
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/virtualenv.py", line 901, in create_environment
site_packages=site_packages, clear=clear))
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/virtualenv.py", line 1209, in install_python
proc_stdout = proc_stdout.strip().decode(sys.getdefaultencoding())
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 21: ordinal not in range(128)
```

That `sys.getdefaultencoding` should probably be `sys.getfilesystemencoding`, since it's a filesystem path that's being decoded.