Skip to content

Commit d04a213

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 c26af2b commit d04a213

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
@@ -844,14 +844,7 @@ oserror_parse_args(PyObject **p_args,
844844
winerrcode = PyLong_AsLong(*winerror);
845845
if (winerrcode == -1 && PyErr_Occurred())
846846
return -1;
847-
/* Set errno to the corresponding POSIX errno (overriding
848-
first argument). Windows Socket error codes (>= 10000)
849-
have the same value as their POSIX counterparts.
850-
*/
851-
if (winerrcode < 10000)
852-
errcode = winerror_to_errno(winerrcode);
853-
else
854-
errcode = winerrcode;
847+
errcode = winerror_to_errno(winerrcode);
855848
*myerrno = PyLong_FromLong(errcode);
856849
if (!*myerrno)
857850
return -1;

0 commit comments

Comments
 (0)