Thanks to visit codestin.com
Credit goes to github.com

Skip to content

gh-98793: Fix typecheck in overlapped.c #98835

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Oct 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions Lib/test/test_asyncio/test_windows_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,17 @@ def test_read_self_pipe_restart(self):
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):

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix argument typechecks in :func:`!_overlapped.WSAConnect` and :func:`!_overlapped.Overlapped.WSASendTo` functions.
10 changes: 9 additions & 1 deletion Modules/clinic/overlapped.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions Modules/overlapped.c
Original file line number Diff line number Diff line change
Expand Up @@ -1674,7 +1674,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.
Expand All @@ -1683,7 +1683,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;
Expand Down Expand Up @@ -1717,7 +1717,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.
Expand All @@ -1727,7 +1727,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;
Expand Down