Skip to content

Commit e03d850

Browse files
committed
Fix unrepresentable defaults in socket.sendmsg() signature
1 parent a7541c3 commit e03d850

4 files changed

Lines changed: 17 additions & 6 deletions

File tree

Lib/test/test_socket.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import errno
1313
import fractions
1414
import gc
15+
import inspect
1516
import io
1617
import itertools
1718
import math
@@ -945,6 +946,14 @@ def requireSocket(*args):
945946

946947
class GeneralModuleTests(unittest.TestCase):
947948

949+
@unittest.skipUnless(hasattr(socket.socket, "sendmsg"),
950+
"sendmsg not supported")
951+
def test_sendmsg_signature(self):
952+
self.assertEqual(
953+
str(inspect.signature(socket.socket.sendmsg)),
954+
"(self, buffers, ancdata=(), flags=0, address=None, /)",
955+
)
956+
948957
@unittest.skipUnless(_socket is not None, 'need _socket module')
949958
def test_socket_type(self):
950959
self.assertTrue(gc.is_tracked(_socket.socket))
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Fix the signature of :meth:`socket.socket.sendmsg` to expose the *ancdata*
2+
and *address* defaults as ``()`` and ``None`` instead of
3+
``<unrepresentable>``.

Modules/clinic/socketmodule.c.h

Lines changed: 2 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Modules/socketmodule.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4929,9 +4929,9 @@ sock_sendmsg_impl(PySocketSockObject *s, void *data)
49294929
_socket.socket.sendmsg
49304930
self as s: self(type="PySocketSockObject *")
49314931
buffers as data_arg: object
4932-
ancdata as cmsg_arg: object = NULL
4932+
ancdata as cmsg_arg: object(c_default="NULL") = ()
49334933
flags: int = 0
4934-
address as addr_arg: object = NULL
4934+
address as addr_arg: object(c_default="NULL") = None
49354935
/
49364936
49374937
Send normal and ancillary data to the socket.
@@ -4955,7 +4955,7 @@ static PyObject *
49554955
_socket_socket_sendmsg_impl(PySocketSockObject *s, PyObject *data_arg,
49564956
PyObject *cmsg_arg, int flags,
49574957
PyObject *addr_arg)
4958-
/*[clinic end generated code: output=3b4cb1110644ce39 input=8ae408971a3aa329]*/
4958+
/*[clinic end generated code: output=3b4cb1110644ce39 input=5fdf9b49bed3848b]*/
49594959

49604960
{
49614961
Py_ssize_t i, ndatabufs = 0, ncmsgs, ncmsgbufs = 0;

0 commit comments

Comments
 (0)