Verified Commit d944d2bf authored by Renato Alves's avatar Renato Alves 🌱
Browse files

Fix PermissionError on Windows when deleting an open file

Fixes #16
parent fa6450f9
Pipeline #16655 passed with stage
in 38 seconds
......@@ -1489,6 +1489,12 @@ OMG! I have received A MESSAGE!!!
> > try:
> > yield fh
> > except ZeroDivisionError:
> > # In MacOS & Linux we could simply remove/delete the file
> > # but on Windows we need to close it before attempting deletion
> > # Doing it here will cause the file to be closed twice, once here
> > # and another time by the 'with' above.
> > # However, closing the file multiple times is safe and produces no error
> > fh.close()
> > os.remove(filename)
> > # re-raising the ZeroDivisionError exception ensures we don't silence the error
> > # try omitting the next line and compare the resulting behavior
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment