[proxy] bugs.python.org← back | site home | direct (HTTPS) ↗ | proxy home | ◑ dark◐ light

Issue 32890: os: Some functions may report bogus errors on Windows

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

Messages (6) msg312446 - (view) Author: Alexey Izbyshev (izbyshev) * 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) * 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) * Date: 2018-10-20 00:53
Thanks Alexey Izbyshev!
msg328265 - (view) Author: Alexey Izbyshev (izbyshev) * 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