diff options
author | Benjamin Peterson <benjamin@python.org> | 2012-10-09 11:16:26 -0400 |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2012-10-09 11:16:26 -0400 |
commit | 455fa0a314b7f7edd0c8554b12a65267ff1e2e5b (patch) | |
tree | a4db0395d8674c1e3c4119f0edccf72307b34e49 /Lib/platform.py | |
parent | b29614e047110f4d9af993a6cdec4e3fb7ef9738 (diff) | |
parent | 831893a68ec7114c1fc9c8e36b9159f5c1db50c7 (diff) | |
download | cpython-git-455fa0a314b7f7edd0c8554b12a65267ff1e2e5b.tar.gz |
merge heads
Diffstat (limited to 'Lib/platform.py')
-rwxr-xr-x | Lib/platform.py | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/Lib/platform.py b/Lib/platform.py index b6538227ea..769fe8846d 100755 --- a/Lib/platform.py +++ b/Lib/platform.py @@ -112,7 +112,7 @@ __copyright__ = """ __version__ = '1.0.7' import collections -import sys, os, re +import sys, os, re, subprocess ### Globals & Constants @@ -922,13 +922,15 @@ def _syscmd_file(target,default=''): if sys.platform in ('dos','win32','win16','os2'): # XXX Others too ? return default - target = _follow_symlinks(target).replace('"', '\\"') + target = _follow_symlinks(target) try: - f = os.popen('file -b "%s" 2> %s' % (target, DEV_NULL)) + proc = subprocess.Popen(['file', target], + stdout=subprocess.PIPE, stderr=subprocess.STDOUT) + except (AttributeError,os.error): return default - output = f.read().strip() - rc = f.close() + output = proc.communicate()[0].decode('latin-1') + rc = proc.wait() if not output or rc: return default else: |