This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: [2.7] test.support.unlink() should fail or emit a warning on WindowsError: [Error 32] The process cannot access the file ...
Type: resource usage Stage: resolved
Components: Tests, Windows Versions: Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: jkloth, paul.moore, steve.dower, tim.golden, vstinner, zach.ware
Priority: normal Keywords:

Created on 2017-05-04 00:03 by vstinner, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 1456 merged vstinner, 2017-05-04 15:02
Messages (5)
msg292949 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2017-05-04 00:03
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.
msg292980 - (view) Author: Jeremy Kloth (jkloth) * Date: 2017-05-04 13:55
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.
msg292982 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2017-05-04 13:58
> 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.
msg293076 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2017-05-05 08:27
New changeset 03b278895fa0db355af4e450eac71dd0532db394 by Victor Stinner in branch '2.7':
bpo-30265: support.unlink() don't catch any OSError (#1456)
https://github.com/python/cpython/commit/03b278895fa0db355af4e450eac71dd0532db394
msg293077 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2017-05-05 08:28
Ok, fixed.
History
Date User Action Args
2022-04-11 14:58:46adminsetgithub: 74451
2017-05-05 08:28:25vstinnersetstatus: open -> closed
resolution: fixed
messages: + msg293077

stage: resolved
2017-05-05 08:27:36vstinnersetmessages: + msg293076
2017-05-04 15:02:04vstinnersetpull_requests: + pull_request1554
2017-05-04 13:58:10vstinnersettitle: 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: + msg292982
versions: + Python 2.7, - Python 3.7
2017-05-04 13:55:25jklothsetnosy: + jkloth
messages: + msg292980
2017-05-04 00:03:15vstinnercreate