#16112: platform.architecture does not correctly escape argument to /usr/bin/file. Use 'communicate()' and decode the bytes

This commit is contained in:
Jesus Cea 2012-10-05 04:58:38 +02:00
parent 4ca222d4d5
commit adc8211e00

View file

@ -997,12 +997,11 @@ def _syscmd_file(target,default=''):
return default return default
target = _follow_symlinks(target) target = _follow_symlinks(target)
try: try:
with open(DEV_NULL) as dev_null:
proc = subprocess.Popen(['file', '-b', '--', target], proc = subprocess.Popen(['file', '-b', '--', target],
stdout=subprocess.PIPE, stderr=dev_null) stdout=subprocess.PIPE, stderr=dev_null)
except (AttributeError,os.error): except (AttributeError,os.error):
return default return default
output = proc.stdout.read() output = proc.communicate()[0].decode("latin-1")
rc = proc.wait() rc = proc.wait()
if not output or rc: if not output or rc:
return default return default