summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorJesus Cea <jcea@jcea.es>2012-10-05 02:58:38 (GMT)
committerJesus Cea <jcea@jcea.es>2012-10-05 02:58:38 (GMT)
commitadc8211e0084126c1d3190022929c3bffef12ce6 (patch)
tree9bc54eade4b6c40b0bd426c9408209628b7b64e4 /Lib
parent4ca222d4d5469bd0c9d188b9d007597798919260 (diff)
downloadcpython-adc8211e0084126c1d3190022929c3bffef12ce6.zip
cpython-adc8211e0084126c1d3190022929c3bffef12ce6.tar.gz
cpython-adc8211e0084126c1d3190022929c3bffef12ce6.tar.bz2
#16112: platform.architecture does not correctly escape argument to /usr/bin/file. Use 'communicate()' and decode the bytes
Diffstat (limited to 'Lib')
-rwxr-xr-xLib/platform.py7
1 files changed, 3 insertions, 4 deletions
diff --git a/Lib/platform.py b/Lib/platform.py
index 6776a25..f2dd520 100755
--- a/Lib/platform.py
+++ b/Lib/platform.py
@@ -997,12 +997,11 @@ def _syscmd_file(target,default=''):
return default
target = _follow_symlinks(target)
try:
- with open(DEV_NULL) as dev_null:
- proc = subprocess.Popen(['file', '-b', '--', target],
- stdout=subprocess.PIPE, stderr=dev_null)
+ proc = subprocess.Popen(['file', '-b', '--', target],
+ stdout=subprocess.PIPE, stderr=dev_null)
except (AttributeError,os.error):
return default
- output = proc.stdout.read()
+ output = proc.communicate()[0].decode("latin-1")
rc = proc.wait()
if not output or rc:
return default