https://github.com/python/cpython/commit/798eaca6659f21dda2ea90e65b99ce9d2a1d4128
commit: 798eaca6659f21dda2ea90e65b99ce9d2a1d4128
branch: 3.9
author: Ɓukasz Langa <[email protected]>
committer: ambv <[email protected]>
date: 2025-10-31T16:37:20+01:00
summary:

[3.9] gh-98793: Fix typecheck in `overlapped.c` (GH-98835) (GH-98890) 
(GH-140825)

(cherry picked from commit d3d1738acd4f62869d7f1e119c257e2ee46fd16f)

Co-authored-by: Charlie Zhao <[email protected]>
Co-authored-by: Kumar Aditya <[email protected]>
Co-authored-by: Petr Viktorin <[email protected]>

files:
A Misc/NEWS.d/next/Library/2022-10-29-03-40-18.gh-issue-98793.WSPB4A.rst
M Lib/test/test_asyncio/test_windows_events.py
M Modules/overlapped.c

diff --git a/Lib/test/test_asyncio/test_windows_events.py 
b/Lib/test/test_asyncio/test_windows_events.py
index a8939d58540f47..0e9d09af142833 100644
--- a/Lib/test/test_asyncio/test_windows_events.py
+++ b/Lib/test/test_asyncio/test_windows_events.py
@@ -279,6 +279,17 @@ def threadMain():
         stop.set()
         thr.join()
 
+    def test_address_argument_type_error(self):
+        # Regression test for https://github.com/python/cpython/issues/98793
+        proactor = self.loop._proactor
+        sock = socket.socket(type=socket.SOCK_DGRAM)
+        bad_address = None
+        with self.assertRaises(TypeError):
+            proactor.connect(sock, bad_address)
+        with self.assertRaises(TypeError):
+            proactor.sendto(sock, b'abc', addr=bad_address)
+        sock.close()
+
 
 class WinPolicyTests(WindowsEventsTestCase):
 
diff --git 
a/Misc/NEWS.d/next/Library/2022-10-29-03-40-18.gh-issue-98793.WSPB4A.rst 
b/Misc/NEWS.d/next/Library/2022-10-29-03-40-18.gh-issue-98793.WSPB4A.rst
new file mode 100644
index 00000000000000..7b67af06cf3d17
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2022-10-29-03-40-18.gh-issue-98793.WSPB4A.rst
@@ -0,0 +1 @@
+Fix argument typechecks in :func:`!_overlapped.WSAConnect` and 
:func:`!_overlapped.Overlapped.WSASendTo` functions.
diff --git a/Modules/overlapped.c b/Modules/overlapped.c
index 5f8a82347355d9..0abe5b781138bf 100644
--- a/Modules/overlapped.c
+++ b/Modules/overlapped.c
@@ -1552,7 +1552,9 @@ overlapped_WSAConnect(PyObject *self, PyObject *args)
     int Length;
     int err;
 
-    if (!PyArg_ParseTuple(args, F_HANDLE "O", &ConnectSocket, &AddressObj)) {
+
+    if (!PyArg_ParseTuple(args, F_HANDLE "O!:WSAConnect",
+                          &ConnectSocket, &PyTuple_Type, &AddressObj)) {
         return NULL;
     }
 
@@ -1598,8 +1600,8 @@ Overlapped_WSASendTo(OverlappedObject *self, PyObject 
*args)
     int ret;
     DWORD err;
 
-    if (!PyArg_ParseTuple(args, F_HANDLE "O" F_DWORD "O",
-                          &handle, &bufobj, &flags, &AddressObj))
+    if (!PyArg_ParseTuple(args, F_HANDLE "OkO!:WSASendTo",
+        &handle, &bufobj, &flags, &PyTuple_Type, &AddressObj))
     {
         return NULL;
     }

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]

Reply via email to