Issue 30265: [2.7] test.support.unlink() should fail or emit a warning on WindowsError: [Error 32] The process cannot access the file ... (original) (raw)
Issue30265
Created on 2017-05-04 00:03 by vstinner, last changed 2022-04-11 14:58 by admin. This issue is now closed.
While working on issue #30264, I noticed that test.support.unlink() ignores *all* OSError exceptions. I suggest to add handle WindowsError: [Error 32] differently. Example of such error, issue #15388: WindowsError: [Error 32] The process cannot access the file because it is being used by another process: I suggest to either raise an exception (passthrough the original OSError), or emit/log a warning.
Looking at test.support, the only errors that I can see being ignored by unlink() is FileNotFoundError and NotADirectoryError (line 399). The only bare OSError except clause is on line 359, but for an lstat() call.
> Looking at test.support, the only errors that I can see being ignored by unlink() is FileNotFoundError and NotADirectoryError (line 399) Oh wait, I was looking at Python 2.7 code: def unlink(filename): try: _unlink(filename) except OSError: pass So this issuse seems to be specific to Python 2.7.
status: open -> closedresolution: fixedmessages: + stage: resolved
2017-05-05 08:27:36
vstinner
set
messages: +
2017-05-04 15:02:04
vstinner
set
pull_requests: + <pull%5Frequest1554>
2017-05-04 13:58:10
vstinner
set
title: test.support.unlink() should fail or emit a warning on WindowsError: [Error 32] The process cannot access the file ... -> [2.7] test.support.unlink() should fail or emit a warning on WindowsError: [Error 32] The process cannot access the file ...messages: + versions: + Python 2.7, - Python 3.7