Index: scripts/Python/buildSwigPython.py =================================================================== --- scripts/Python/buildSwigPython.py +++ scripts/Python/buildSwigPython.py @@ -427,6 +427,20 @@ return (bOk, strConfigBldDir, strErrMsg); +""" +Tries to remove given file. If file doesn't exist, the function will not throw. +If an exception is thrown during remove, and errno is not ENOENT, then it will +be rethrown. If errno is ENOENT, it will be ignored. +""" +def removeignoreenoent(filename): + try: + os.remove( strSwigOutputFile ); + except OSError as e: + import errno + if e.errno != errno.ENOENT: + raise + pass + #++--------------------------------------------------------------------------- # Details: Do a SWIG code rebuild. Any number returned by SWIG which is not # zero is treated as an error. The generate dependencies flag decides @@ -587,6 +601,7 @@ return bOk, strMsg; + #----------------------------------------------------------------------------- #----------------------------------------------------------------------------- #----------------------------------------------------------------------------- @@ -683,7 +698,7 @@ # iOS be sure to set LLDB_DISABLE_PYTHON to 1. if (strEnvVarLLDBDisablePython != None) and \ (strEnvVarLLDBDisablePython == "1"): - os.remove( strSwigOutputFile ); + removeignoreenoent( strSwigOutputFile ) open( strSwigOutputFile, 'w' ).close(); # Touch the file if bDebug: strMsg = strMsgLldbDisablePython; @@ -696,7 +711,7 @@ None ); if (strEnvVarGccPreprocessDefs != None) or \ (strEnvVarLLDBDisablePython != None): - os.remove( strSwigOutputFile ); + removeignoreenoent( strSwigOutputFile ) open( strSwigOutputFile, 'w' ).close(); # Touch the file if bDebug: strMsg = strMsgLldbDisableGccEnv;