mirror of
https://github.com/python/cpython.git
synced 2025-07-24 11:44:31 +00:00
[3.11] gh-98793: Fix typecheck in overlapped.c
(GH-98835) (#98889)
Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
(cherry picked from commit 3ac8c0ab6e
)
This commit is contained in:
parent
a4f8db19ad
commit
2b0cbb90c3
4 changed files with 21 additions and 9 deletions
|
@ -239,6 +239,17 @@ class ProactorTests(test_utils.TestCase):
|
|||
self.close_loop(self.loop)
|
||||
self.assertFalse(self.loop.call_exception_handler.called)
|
||||
|
||||
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(test_utils.TestCase):
|
||||
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
Fix argument typechecks in :func:`!_overlapped.WSAConnect` and :func:`!_overlapped.Overlapped.WSASendTo` functions.
|
10
Modules/clinic/overlapped.c.h
generated
10
Modules/clinic/overlapped.c.h
generated
|
@ -851,8 +851,8 @@ _overlapped_WSAConnect(PyObject *module, PyObject *const *args, Py_ssize_t nargs
|
|||
HANDLE ConnectSocket;
|
||||
PyObject *AddressObj;
|
||||
|
||||
if (!_PyArg_ParseStack(args, nargs, ""F_HANDLE"O:WSAConnect",
|
||||
&ConnectSocket, &AddressObj)) {
|
||||
if (!_PyArg_ParseStack(args, nargs, ""F_HANDLE"O!:WSAConnect",
|
||||
&ConnectSocket, &PyTuple_Type, &AddressObj)) {
|
||||
goto exit;
|
||||
}
|
||||
return_value = _overlapped_WSAConnect_impl(module, ConnectSocket, AddressObj);
|
||||
|
@ -884,8 +884,8 @@ _overlapped_Overlapped_WSASendTo(OverlappedObject *self, PyObject *const *args,
|
|||
DWORD flags;
|
||||
PyObject *AddressObj;
|
||||
|
||||
if (!_PyArg_ParseStack(args, nargs, ""F_HANDLE"y*kO:WSASendTo",
|
||||
&handle, &bufobj, &flags, &AddressObj)) {
|
||||
if (!_PyArg_ParseStack(args, nargs, ""F_HANDLE"y*kO!:WSASendTo",
|
||||
&handle, &bufobj, &flags, &PyTuple_Type, &AddressObj)) {
|
||||
goto exit;
|
||||
}
|
||||
return_value = _overlapped_Overlapped_WSASendTo_impl(self, handle, &bufobj, flags, AddressObj);
|
||||
|
@ -968,4 +968,4 @@ exit:
|
|||
|
||||
return return_value;
|
||||
}
|
||||
/*[clinic end generated code: output=8532bc0e4e1958ac input=a9049054013a1b77]*/
|
||||
/*[clinic end generated code: output=5023f7748f0e073e input=a9049054013a1b77]*/
|
||||
|
|
|
@ -1684,7 +1684,7 @@ Overlapped_traverse(OverlappedObject *self, visitproc visit, void *arg)
|
|||
_overlapped.WSAConnect
|
||||
|
||||
client_handle as ConnectSocket: HANDLE
|
||||
address_as_bytes as AddressObj: object
|
||||
address_as_bytes as AddressObj: object(subclass_of='&PyTuple_Type')
|
||||
/
|
||||
|
||||
Bind a remote address to a connectionless (UDP) socket.
|
||||
|
@ -1693,7 +1693,7 @@ Bind a remote address to a connectionless (UDP) socket.
|
|||
static PyObject *
|
||||
_overlapped_WSAConnect_impl(PyObject *module, HANDLE ConnectSocket,
|
||||
PyObject *AddressObj)
|
||||
/*[clinic end generated code: output=ea0b4391e94dad63 input=169f8075e9ae7fa4]*/
|
||||
/*[clinic end generated code: output=ea0b4391e94dad63 input=7cf65313d49c015a]*/
|
||||
{
|
||||
char AddressBuf[sizeof(struct sockaddr_in6)];
|
||||
SOCKADDR *Address = (SOCKADDR*)AddressBuf;
|
||||
|
@ -1727,7 +1727,7 @@ _overlapped.Overlapped.WSASendTo
|
|||
handle: HANDLE
|
||||
buf as bufobj: Py_buffer
|
||||
flags: DWORD
|
||||
address_as_bytes as AddressObj: object
|
||||
address_as_bytes as AddressObj: object(subclass_of='&PyTuple_Type')
|
||||
/
|
||||
|
||||
Start overlapped sendto over a connectionless (UDP) socket.
|
||||
|
@ -1737,7 +1737,7 @@ static PyObject *
|
|||
_overlapped_Overlapped_WSASendTo_impl(OverlappedObject *self, HANDLE handle,
|
||||
Py_buffer *bufobj, DWORD flags,
|
||||
PyObject *AddressObj)
|
||||
/*[clinic end generated code: output=3cdedc4cfaeb70cd input=b7c1749a62e2e374]*/
|
||||
/*[clinic end generated code: output=3cdedc4cfaeb70cd input=31f44cd4ab92fc33]*/
|
||||
{
|
||||
char AddressBuf[sizeof(struct sockaddr_in6)];
|
||||
SOCKADDR *Address = (SOCKADDR*)AddressBuf;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue