gh-155621: Fix unrepresentable defaults in socket.sendmsg() signature (#155623)

kumaraditya303 <[email protected]>
Newsgroups gmane.comp.python.cvs
Message-ID <[email protected]>
https://github.com/python/cpython/commit/e5556cdf71f7f5561fcaca21f6e680ebdd44cffb
commit: e5556cdf71f7f5561fcaca21f6e680ebdd44cffb
branch: main
author: stevens <[email protected]>
committer: kumaraditya303 <[email protected]>
date: 2026-08-14T15:33:42Z
summary:

gh-155621: Fix unrepresentable defaults in socket.sendmsg() signature (#155623)

files:
M Lib/test/test_inspect/test_inspect.py
M Modules/clinic/socketmodule.c.h
M Modules/socketmodule.c

diff --git a/Lib/test/test_inspect/test_inspect.py b/Lib/test/test_inspect/test_inspect.py
index 76c346cd89eac04..ff7475447e95a03 100644
--- a/Lib/test/test_inspect/test_inspect.py
+++ b/Lib/test/test_inspect/test_inspect.py
@@ -6340,7 +6340,7 @@ def test_socket_module_has_signatures(self):
         # depends on the number of the arguments.
         methods_no_signature = {'ioctl', 'sendto', 'setsockopt'}
         # These have parameters with unrepresentable default values.
-        methods_unsupported_signature = {'listen', 'sendmsg', 'sendmsg_afalg'}
+        methods_unsupported_signature = {'listen', 'sendmsg_afalg'}
         defined = vars(socket.SocketType).keys()
         self._test_module_has_signatures(socket,
                 no_signature, unsupported_signature,
diff --git a/Modules/clinic/socketmodule.c.h b/Modules/clinic/socketmodule.c.h
index 00e5fb4cde3aefd..f89b91b9b997532 100644
--- a/Modules/clinic/socketmodule.c.h
+++ b/Modules/clinic/socketmodule.c.h
@@ -1018,8 +1018,7 @@ _socket_socket_sendall(PyObject *s, PyObject *const *args, Py_ssize_t nargs)
 #if defined(CMSG_LEN)
 
 PyDoc_STRVAR(_socket_socket_sendmsg__doc__,
-"sendmsg($self, buffers, ancdata=<unrepresentable>, flags=0,\n"
-"        address=<unrepresentable>, /)\n"
+"sendmsg($self, buffers, ancdata=(), flags=0, address=None, /)\n"
 "--\n"
 "\n"
 "Send normal and ancillary data to the socket.\n"
@@ -2479,4 +2478,4 @@ _socket_CMSG_SPACE(PyObject *module, PyObject *arg)
 #ifndef _SOCKET_CMSG_SPACE_METHODDEF
     #define _SOCKET_CMSG_SPACE_METHODDEF
 #endif /* !defined(_SOCKET_CMSG_SPACE_METHODDEF) */
-/*[clinic end generated code: output=133662a8c304b1b7 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=acc30d6fdeb54e90 input=a9049054013a1b77]*/
diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c
index 9051420179aea11..70d3738b176cda2 100644
--- a/Modules/socketmodule.c
+++ b/Modules/socketmodule.c
@@ -4990,9 +4990,9 @@ sock_sendmsg_impl(PySocketSockObject *s, void *data)
 _socket.socket.sendmsg
     self as s: self(type="PySocketSockObject *")
     buffers as data_arg: object
-    ancdata as cmsg_arg: object = NULL
+    ancdata as cmsg_arg: object(c_default="NULL") = ()
     flags: int = 0
-    address as addr_arg: object = NULL
+    address as addr_arg: object(c_default="NULL") = None
     /
 
 Send normal and ancillary data to the socket.
@@ -5016,7 +5016,7 @@ static PyObject *
 _socket_socket_sendmsg_impl(PySocketSockObject *s, PyObject *data_arg,
                             PyObject *cmsg_arg, int flags,
                             PyObject *addr_arg)
-/*[clinic end generated code: output=3b4cb1110644ce39 input=8ae408971a3aa329]*/
+/*[clinic end generated code: output=3b4cb1110644ce39 input=5fdf9b49bed3848b]*/
 
 {
     Py_ssize_t i, ndatabufs = 0, ncmsgs, ncmsgbufs = 0;

_______________________________________________
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]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.