]> 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:50:17 +0000 (04:50 +0200)
committerJesus Cea <jcea@jcea.es>
Fri, 5 Oct 2012 02:50:17 +0000 (04:50 +0200)
Lib/platform.py

index d1774995738f6ddfcf9334a3c099adf1d097db35..10b04bde95ef3646d5fd0785f08de221f3361244 100755 (executable)
@@ -1045,13 +1045,12 @@ 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=subprocess.DEVNULL)
 
     except (AttributeError,os.error):
         return default
-    output = proc.stdout.read()
+    output = proc.communicate()[0]
     rc = proc.wait()
     if not output or rc:
         return default