[Lldb-commits] [lldb] r229334 - os.remove shouldn't fail, if file doesn't exist
Ismail Pazarbasi
ismail.pazarbasi at gmail.com
Sun Feb 15 13:50:28 PST 2015
Author: ismailp
Date: Sun Feb 15 15:50:28 2015
New Revision: 229334
URL: http://llvm.org/viewvc/llvm-project?rev=229334&view=rev
Log:
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
Modified:
lldb/trunk/scripts/Python/buildSwigPython.py
Modified: lldb/trunk/scripts/Python/buildSwigPython.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/buildSwigPython.py?rev=229334&r1=229333&r2=229334&view=diff
==============================================================================
--- lldb/trunk/scripts/Python/buildSwigPython.py (original)
+++ lldb/trunk/scripts/Python/buildSwigPython.py Sun Feb 15 15:50:28 2015
@@ -429,6 +429,18 @@ def get_config_build_dir( vDictArgs, vst
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;
More information about the lldb-commits
mailing list