[Python-checkins] bpo-46775: OSError should call winerror_to_errno unconditionally on Windows (GH-32179)

miss-islington webhook-mailer at python.org
Wed Mar 30 21:48:45 EDT 2022


https://github.com/python/cpython/commit/1f2ec4cef1804cda9d2df99a318373b2982919e9
commit: 1f2ec4cef1804cda9d2df99a318373b2982919e9
branch: 3.10
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: miss-islington <31488909+miss-islington at users.noreply.github.com>
date: 2022-03-30T18:48:31-07:00
summary:

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

(cherry picked from commit d0c67ea0645b7ad37b867c167882a346a24de641)

Co-authored-by: Dong-hee Na <donghee.na at python.org>

files:
A Misc/NEWS.d/next/Core and Builtins/2022-03-30-02-36-25.bpo-46775.e3Oxqf.rst
M Objects/exceptions.c

diff --git a/Misc/NEWS.d/next/Core and Builtins/2022-03-30-02-36-25.bpo-46775.e3Oxqf.rst b/Misc/NEWS.d/next/Core and Builtins/2022-03-30-02-36-25.bpo-46775.e3Oxqf.rst
new file mode 100644
index 0000000000000..da56ecd89367b
--- /dev/null
+++ b/Misc/NEWS.d/next/Core and Builtins/2022-03-30-02-36-25.bpo-46775.e3Oxqf.rst	
@@ -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.
diff --git a/Objects/exceptions.c b/Objects/exceptions.c
index 6537a7ccd1e3c..9639b4436a078 100644
--- a/Objects/exceptions.c
+++ b/Objects/exceptions.c
@@ -847,14 +847,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;



More information about the Python-checkins mailing list