[New-bugs-announce] [issue3719] platform.py: _syscmd_file() can't handle target path with space or special shell character
report at bugs.python.org
Fri Aug 29 02:40:13 CEST 2008
New submission from jfdp <joe.dipol at sun.com>:
If you install python in a location which has a space
or shell character in the path then platform.platform()
will generate an error and/or fail to get all platform
Python 2.4.4 (#8, Apr 11 2008, 11:42:39) [C] on sunos5
Type "help", "copyright", "credits" or "license" for more information.
>>> import platform
>>> print platform.platform()
sh: syntax error at line 1: `(' unexpected
Note the error from 'sh' was well as the fact that "ELF"
is missing from the platform string. If you are in a path
with a space then it silently fails to identify "ELF".
The problem is in platform.py: _syscmd_file(target,default='')
in particular this line:
f = os.popen('file %s 2> /dev/null' % target)
This should be:
f = os.popen('file "%s" 2> /dev/null' % target)
Note the double quotes to protect the path from the shell.
I've examined the 2.5, 2.6 and 3.0 source and they all
have this same problem.
components: Library (Lib)
title: platform.py: _syscmd_file() can't handle target path with space or special shell character
versions: Python 2.4
Python tracker <report at bugs.python.org>
More information about the New-bugs-announce