[Checkins] SVN: zc.buildout/branches/python-3-2/src/zc/buildout/testing.py Fix IO encoding on Python 3.2 for subprocess interaction to detect other
Christian Theune
ct at gocept.com
Thu Apr 7 04:29:23 EDT 2011
Log message for revision 121321:
Fix IO encoding on Python 3.2 for subprocess interaction to detect other
installed Python versions. (Doesn't completely fix selecting-python.txt,
though.)
Changed:
U zc.buildout/branches/python-3-2/src/zc/buildout/testing.py
-=-
Modified: zc.buildout/branches/python-3-2/src/zc/buildout/testing.py
===================================================================
--- zc.buildout/branches/python-3-2/src/zc/buildout/testing.py 2011-04-07 08:20:08 UTC (rev 121320)
+++ zc.buildout/branches/python-3-2/src/zc/buildout/testing.py 2011-04-07 08:29:22 UTC (rev 121321)
@@ -193,7 +193,13 @@
if os.path.exists(e):
return e
else:
- cmd = 'python%s -c "import sys; print(sys.executable)"' % version
+ if version.startswith('2.'):
+ cmd = ('python%s -c "import sys; print(sys.executable.decode('
+ 'sys.getfilesystemencoding()).encode(\'utf-8\'))"' %
+ version)
+ else:
+ cmd = ('python%s -c "import sys; print('
+ 'sys.executable.encode(\'utf-8\'))"' % version)
p = subprocess.Popen(cmd,
shell=True,
stdin=subprocess.PIPE,
@@ -202,7 +208,7 @@
close_fds=MUST_CLOSE_FDS)
i, o = (p.stdin, p.stdout)
i.close()
- e = o.read().strip()
+ e = o.read().decode('utf-8').strip()
o.close()
if os.path.exists(e):
return e
@@ -215,10 +221,15 @@
close_fds=MUST_CLOSE_FDS)
i, o = (p.stdin, p.stdout)
i.close()
- e = o.read().strip()
+ e = o.read().decode('ascii').strip()
o.close()
if e == version:
- cmd = 'python -c "import sys; print(sys.executable)"'
+ if version.startswith('2.'):
+ cmd = ('python -c "import sys; print(sys.executable.decode('
+ 'sys.getfilesystemencoding()).encode(\'utf-8\'))"')
+ else:
+ cmd = ('python -c "import sys; print('
+ 'sys.executable.encode(\'utf-8\'))"')
p = subprocess.Popen(cmd,
shell=True,
stdin=subprocess.PIPE,
@@ -227,7 +238,7 @@
close_fds=MUST_CLOSE_FDS)
i, o = (p.stdin, p.stdout)
i.close()
- e = o.read().strip()
+ e = o.read().decode('utf-8').strip()
o.close()
if os.path.exists(e):
return e
More information about the checkins
mailing list