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: os: Some functions may report bogus errors on Windows
Type: behavior Stage: resolved
Components: Versions: Python 3.8, Python 3.7, Python 3.6
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: izbyshev, miss-islington, vstinner
Priority: normal Keywords: patch

Created on 2018-02-20 23:54 by izbyshev, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 5784 merged izbyshev, 2018-02-21 00:05
PR 9984 merged miss-islington, 2018-10-20 00:28
PR 9985 merged miss-islington, 2018-10-20 00:28
Messages (6)
msg312446 - (view) Author: Alexey Izbyshev (izbyshev) * (Python triager) Date: 2018-02-20 23:54
Demo:

>>> os.execve('', ['a'], {})
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
OSError: [WinError 0] The operation completed successfully: ''

The reason is that path_error() used throughout os module always uses GetLastError() on Windows, but some functions are implemented via CRT calls which report errors via errno. It seems that commit 292c83554 caused this issue.
msg328101 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2018-10-20 00:28
New changeset 834603112e6ca35944dd21105b01fca562dc3241 by Victor Stinner (Alexey Izbyshev) in branch 'master':
bpo-32890, os: Use errno instead of GetLastError() in execve() and truncate() (GH-5784)
https://github.com/python/cpython/commit/834603112e6ca35944dd21105b01fca562dc3241
msg328110 - (view) Author: miss-islington (miss-islington) Date: 2018-10-20 00:46
New changeset 8f53dcdb246a3acb0e64b742c35b5f785bd19092 by Miss Islington (bot) in branch '3.7':
bpo-32890, os: Use errno instead of GetLastError() in execve() and truncate() (GH-5784)
https://github.com/python/cpython/commit/8f53dcdb246a3acb0e64b742c35b5f785bd19092
msg328113 - (view) Author: miss-islington (miss-islington) Date: 2018-10-20 00:49
New changeset d9a2665fc4573c4d311a89750737ad4cc3310252 by Miss Islington (bot) in branch '3.6':
bpo-32890, os: Use errno instead of GetLastError() in execve() and truncate() (GH-5784)
https://github.com/python/cpython/commit/d9a2665fc4573c4d311a89750737ad4cc3310252
msg328118 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2018-10-20 00:53
Thanks Alexey Izbyshev!
msg328265 - (view) Author: Alexey Izbyshev (izbyshev) * (Python triager) Date: 2018-10-22 17:29
Python 2.7 doesn't have the same issue.

In os.execve(), posix_error() is used, but it is based on errno, which is correct. (A funny bit is that os.execve('', ['a'], {}) crashes in 2.7, probably because of some checks in CRT).

And os.truncate() is not implemented in 2.7 at all.
History
Date User Action Args
2022-04-11 14:58:58adminsetgithub: 77071
2018-10-22 17:29:14izbyshevsetmessages: + msg328265
versions: - Python 2.7
2018-10-22 13:42:21vstinnersetversions: + Python 2.7, Python 3.8
2018-10-20 00:53:37vstinnersetstatus: open -> closed
resolution: fixed
messages: + msg328118

stage: patch review -> resolved
2018-10-20 00:49:03miss-islingtonsetmessages: + msg328113
2018-10-20 00:46:30miss-islingtonsetnosy: + miss-islington
messages: + msg328110
2018-10-20 00:28:47miss-islingtonsetpull_requests: + pull_request9326
2018-10-20 00:28:37miss-islingtonsetpull_requests: + pull_request9325
2018-10-20 00:28:26vstinnersetmessages: + msg328101
2018-02-21 00:05:36izbyshevsetkeywords: + patch
stage: patch review
pull_requests: + pull_request5565
2018-02-20 23:54:16izbyshevcreate