summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2022-03-31 01:49:40 (GMT)
committerGitHub <noreply@github.com>2022-03-31 01:49:40 (GMT)
commitd04a21344ae69c66f5a6df69ee6fa6988a69b89d (patch)
treeebc0cba101fbe424d8310a5bbd1f11fbbbf7255f
parentc26af2bc531eb114c378cdad81935f6e838a7ee0 (diff)
downloadcpython-d04a21344ae69c66f5a6df69ee6fa6988a69b89d.zip
cpython-d04a21344ae69c66f5a6df69ee6fa6988a69b89d.tar.gz
cpython-d04a21344ae69c66f5a6df69ee6fa6988a69b89d.tar.bz2
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@python.org>
-rw-r--r--Misc/NEWS.d/next/Core and Builtins/2022-03-30-02-36-25.bpo-46775.e3Oxqf.rst3
-rw-r--r--Objects/exceptions.c9
2 files changed, 4 insertions, 8 deletions
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 0000000..da56ecd
--- /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 e67ecfa..57ddbb0 100644
--- a/Objects/exceptions.c
+++ b/Objects/exceptions.c
@@ -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;