Skip to content

Commit 1f2ec4c

Browse files
bpo-46775: OSError should call winerror_to_errno unconditionally on Windows (GH-32179)
(cherry picked from commit d0c67ea) Co-authored-by: Dong-hee Na <[email protected]>
1 parent 66cde7c commit 1f2ec4c

File tree

2 files changed

+4
-8
lines changed

2 files changed

+4
-8
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Some Windows system error codes(>= 10000) are now mapped into
2+
the correct errno and may now raise a subclass of :exc:`OSError`.
3+
Patch by Dong-hee Na.

Objects/exceptions.c

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -847,14 +847,7 @@ oserror_parse_args(PyObject **p_args,
847847
winerrcode = PyLong_AsLong(*winerror);
848848
if (winerrcode == -1 && PyErr_Occurred())
849849
return -1;
850-
/* Set errno to the corresponding POSIX errno (overriding
851-
first argument). Windows Socket error codes (>= 10000)
852-
have the same value as their POSIX counterparts.
853-
*/
854-
if (winerrcode < 10000)
855-
errcode = winerror_to_errno(winerrcode);
856-
else
857-
errcode = winerrcode;
850+
errcode = winerror_to_errno(winerrcode);
858851
*myerrno = PyLong_FromLong(errcode);
859852
if (!*myerrno)
860853
return -1;

0 commit comments

Comments
 (0)