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

Ismail Pazarbasi ismail.pazarbasi at gmail.com
Fri Nov 21 14:14:46 PST 2014


================
Comment at: scripts/Python/buildSwigPython.py:686-687
@@ -685,4 +685,4 @@
 	   (strEnvVarLLDBDisablePython == "1"):
 		os.remove( strSwigOutputFile );
 		open( strSwigOutputFile, 'w' ).close(); # Touch the file
 		if bDebug:
----------------
emaste wrote:
> Do we not have the same issue here?
Presumably, yes. I wasn't trying with `LLDB_DISABLE_PYTHON`, but with CMake generated Xcode project on Darwin, and region below failed. I didn't examine all instances of `os.remove`, I guess I should have.

How about:
```
def removeignoreenoent(filename):
  try:
    os.remove(filename)
  except OSError as e:
    import errno
    if e.errno != errno.ENOENT:
      raise
    pass
```
and call this function instead of os.remove. We might use a better/shorter name; any suggestions?

http://reviews.llvm.org/D6362






More information about the lldb-commits mailing list