Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit cb95996

Browse files
committed
MERGE: #16112: platform.architecture does not correctly escape argument to /usr/bin/file. Fix original patch
2 parents e7f9037 + 685fffa commit cb95996

1 file changed

Lines changed: 3 additions & 4 deletions

File tree

Lib/platform.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -924,13 +924,12 @@ def _syscmd_file(target,default=''):
924924
return default
925925
target = _follow_symlinks(target)
926926
try:
927-
with open(DEV_NULL) as dev_null:
928-
proc = subprocess.Popen(['file', '-b', '--', target],
929-
stdout=subprocess.PIPE, stderr=dev_null)
927+
proc = subprocess.Popen(['file', target],
928+
stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
930929

931930
except (AttributeError,os.error):
932931
return default
933-
output = proc.stdout.read()
932+
output = proc.communicate()[0].decode('latin-1')
934933
rc = proc.wait()
935934
if not output or rc:
936935
return default

0 commit comments

Comments
 (0)