• Victor Stinner's avatar
    Issue #22636: Avoid using a shell in the ctypes.util module · eb063011
    Victor Stinner yazdı
    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.
    eb063011
util.py 10.3 KB