diff -r 54154be6b27d Lib/platform.py --- a/Lib/platform.py Thu Oct 04 22:59:45 2012 +0200 +++ b/Lib/platform.py Fri Oct 05 00:01:20 2012 +0200 @@ -910,7 +910,7 @@ def _syscmd_uname(option,default=''): else: return output -def _syscmd_file(target,default=''): +def _syscmd_file(target,default=b''): """ Interface to the system's file command. @@ -924,13 +924,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 @@ -983,7 +982,7 @@ def architecture(executable=sys.executab if executable: fileout = _syscmd_file(executable, '') else: - fileout = '' + fileout = b'' if not fileout and \ executable == sys.executable: @@ -997,31 +996,31 @@ def architecture(executable=sys.executab linkage = l return bits,linkage - if 'executable' not in fileout: + if b'executable' not in fileout: # Format not supported return bits,linkage # Bits - if '32-bit' in fileout: + if b'32-bit' in fileout: bits = '32bit' - elif 'N32' in fileout: + elif b'N32' in fileout: # On Irix only bits = 'n32bit' - elif '64-bit' in fileout: + elif b'64-bit' in fileout: bits = '64bit' # Linkage - if 'ELF' in fileout: + if b'ELF' in fileout: linkage = 'ELF' - elif 'PE' in fileout: + elif b'PE' in fileout: # E.g. Windows uses this format if 'Windows' in fileout: linkage = 'WindowsPE' else: linkage = 'PE' - elif 'COFF' in fileout: + elif b'COFF' in fileout: linkage = 'COFF' - elif 'MS-DOS' in fileout: + elif b'MS-DOS' in fileout: linkage = 'MSDOS' else: # XXX the A.OUT format also falls under this class...