diff options
author | Ismail Pazarbasi <ismail.pazarbasi@gmail.com> | 2015-02-15 21:50:28 +0000 |
---|---|---|
committer | Ismail Pazarbasi <ismail.pazarbasi@gmail.com> | 2015-02-15 21:50:28 +0000 |
commit | 323e3b6ae071861d24f89951791316a21cb74574 (patch) | |
tree | 91f78590d83bcc01fdd723d102fa4c5b042d1534 /lldb/scripts/Python | |
parent | b1607ab3543cb6500a44b69ebea72110ed03a8fa (diff) | |
download | bcm5719-llvm-323e3b6ae071861d24f89951791316a21cb74574.tar.gz bcm5719-llvm-323e3b6ae071861d24f89951791316a21cb74574.zip |
os.remove shouldn't fail, if file doesn't exist
Summary:
os.remove might throw an exception (of type OSError), if given file
doesn't exist. Catch the exception, and ignore it //iff// errno is
ENOENT. Rethrow the exception, if errno is not ENOENT.
Reviewers: emaste
Subscribers: llvm-commits
Differential Revision: http://reviews.llvm.org/D6362
llvm-svn: 229334
Diffstat (limited to 'lldb/scripts/Python')
-rw-r--r-- | lldb/scripts/Python/buildSwigPython.py | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/lldb/scripts/Python/buildSwigPython.py b/lldb/scripts/Python/buildSwigPython.py index 57ebc4692d3..5eff25f3bcd 100644 --- a/lldb/scripts/Python/buildSwigPython.py +++ b/lldb/scripts/Python/buildSwigPython.py @@ -429,6 +429,18 @@ def get_config_build_dir( vDictArgs, vstrFrameworkPythonDir ): return (bOk, strConfigBldDir, strErrMsg); +""" +Removes given file, ignoring error if it doesn't exist. +""" +def remove_ignore_enoent(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 @@ -685,7 +697,7 @@ def main( vDictArgs ): # iOS be sure to set LLDB_DISABLE_PYTHON to 1. if (strEnvVarLLDBDisablePython != None) and \ (strEnvVarLLDBDisablePython == "1"): - os.remove( strSwigOutputFile ); + remove_ignore_enoent( strSwigOutputFile ) open( strSwigOutputFile, 'w' ).close(); # Touch the file if bDebug: strMsg = strMsgLldbDisablePython; @@ -698,7 +710,7 @@ def main( vDictArgs ): None ); if (strEnvVarGccPreprocessDefs != None) or \ (strEnvVarLLDBDisablePython != None): - os.remove( strSwigOutputFile ); + remove_ignore_enoent( strSwigOutputFile ) open( strSwigOutputFile, 'w' ).close(); # Touch the file if bDebug: strMsg = strMsgLldbDisableGccEnv; |