Created on 2018-02-20 23:54 by izbyshev, last changed 2022-04-11 14:58 by admin. This issue is now closed.
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.
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
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
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
Thanks Alexey Izbyshev!
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.
stage: patch review -> resolved