]> granicus.if.org Git - python/commitdiff
#16112: platform.architecture does not correctly escape argument to /usr/bin/file...
authorJesus Cea <jcea@jcea.es>
Fri, 5 Oct 2012 02:58:38 +0000 (04:58 +0200)
committerJesus Cea <jcea@jcea.es>
Fri, 5 Oct 2012 02:58:38 +0000 (04:58 +0200)
Lib/platform.py

index 6776a2515dbc296253471a4437d02b97b3658411..f2dd5206e30b9c9d6eaede57af1e56e2f360b21f 100755 (executable)
@@ -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