bpo-46775: OSError should call winerror_to_errno unconditionally on Windows (GH-32179)

(cherry picked from commit d0c67ea064)

Co-authored-by: Dong-hee Na <donghee.na@python.org>
This commit is contained in:
Miss Islington (bot) 2022-03-30 18:49:40 -07:00 committed by GitHub
parent c26af2bc53
commit d04a21344a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 8 deletions

View File

@ -0,0 +1,3 @@
Some Windows system error codes(>= 10000) are now mapped into
the correct errno and may now raise a subclass of :exc:`OSError`.
Patch by Dong-hee Na.

View File

@ -844,14 +844,7 @@ oserror_parse_args(PyObject **p_args,
winerrcode = PyLong_AsLong(*winerror);
if (winerrcode == -1 && PyErr_Occurred())
return -1;
/* Set errno to the corresponding POSIX errno (overriding
first argument). Windows Socket error codes (>= 10000)
have the same value as their POSIX counterparts.
*/
if (winerrcode < 10000)
errcode = winerror_to_errno(winerrcode);
else
errcode = winerrcode;
errcode = winerror_to_errno(winerrcode);
*myerrno = PyLong_FromLong(errcode);
if (!*myerrno)
return -1;