[Lldb-commits] [PATCH] os.remove shouldn't fail, if file doesn't exist

Ismail Pazarbasi ismail.pazarbasi at gmail.com
Sun Feb 15 13:52:48 PST 2015


REPOSITORY
  rL LLVM

http://reviews.llvm.org/D6362

Files:
  lldb/trunk/scripts/Python/buildSwigPython.py

Index: lldb/trunk/scripts/Python/buildSwigPython.py
===================================================================
--- lldb/trunk/scripts/Python/buildSwigPython.py
+++ lldb/trunk/scripts/Python/buildSwigPython.py
@@ -429,6 +429,18 @@
 	
 	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 @@
     # 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 @@
 											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;

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D6362.19988.patch
Type: text/x-patch
Size: 1430 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20150215/e339fcb3/attachment.bin>


More information about the lldb-commits mailing list