]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
Issue #22636: Avoid using a shell in the ctypes.util module
authorVictor Stinner <victor.stinner@gmail.com>
Thu, 16 Oct 2014 07:42:45 +0000 (09:42 +0200)
committerVictor Stinner <victor.stinner@gmail.com>
Thu, 16 Oct 2014 07:42:45 +0000 (09:42 +0200)
commiteb063011ab6628d45cffab2f41947866b0d00e8d
treee97c81665772cd7ce8af965cb741fea86423d048
parentf46d3afc51d0081ad1515a52d12b96fa26d1edd4
Issue #22636: Avoid using a shell in the ctypes.util module

Replace os.popen() with subprocess.Popen.

If the "gcc", "cc" or "objdump" command is not available, the code was
supposed to raise an OSError exception. But there was a bug in the code. The
shell code returns the exit code 10 if the required command is missing, and the
code tries to check for the status 10. The problem is that os.popen() doesn't
return the exit code directly, but a status which should be processed by
os.WIFEXITED() and os.WEXITSTATUS(). In practice, the exception was never
raised. The OSError exception was not documented and ctypes.util.find_library()
is expected to return None if the library is not found.

Based on patch by Victor Stinner.
Lib/ctypes/test/test_find.py
Lib/ctypes/util.py
Misc/NEWS