Bug report
Description
The Argument Clinic definition for socket.socket.sendmsg() uses the C value
NULL as the declared default for both ancdata and address:
ancdata as cmsg_arg: object = NULL
flags: int = 0
address as addr_arg: object = NULL
Argument Clinic therefore generates <unrepresentable> as their Python
defaults. This exposes an inaccurate text signature and prevents
inspect.signature() from producing a signature for the method.
Both defaults have natural Python representations:
- an omitted
ancdata is handled as an empty sequence, so its Python default
is ();
- an omitted
address is handled like None, and explicitly passing None
is supported.
Minimal reproducer
Run on a platform that provides socket.socket.sendmsg():
import inspect
import socket
print(socket.socket.sendmsg.__text_signature__)
print(inspect.signature(socket.socket.sendmsg))
Actual behavior
The generated signature contains:
ancdata=<unrepresentable>
address=<unrepresentable>
inspect.signature() raises:
ValueError: <method 'sendmsg' of '_socket.socket' objects> builtin has invalid signature
Nevertheless, omitting both arguments is valid:
import socket
left, right = socket.socketpair()
with left, right:
print(left.sendmsg([b"x"]))
print(right.recv(1))
Expected behavior
The generated text signature should use representable Python defaults, and
inspect.signature() should return a valid signature equivalent to:
(self, buffers, ancdata=(), flags=0, address=None, /)
CPython versions tested on:
CPython main branch
Operating systems tested on:
Linux
Linked PRs
Bug report
Description
The Argument Clinic definition for
socket.socket.sendmsg()uses the C valueNULLas the declared default for bothancdataandaddress:Argument Clinic therefore generates
<unrepresentable>as their Pythondefaults. This exposes an inaccurate text signature and prevents
inspect.signature()from producing a signature for the method.Both defaults have natural Python representations:
ancdatais handled as an empty sequence, so its Python defaultis
();addressis handled likeNone, and explicitly passingNoneis supported.
Minimal reproducer
Run on a platform that provides
socket.socket.sendmsg():Actual behavior
The generated signature contains:
inspect.signature()raises:Nevertheless, omitting both arguments is valid:
Expected behavior
The generated text signature should use representable Python defaults, and
inspect.signature()should return a valid signature equivalent to:CPython versions tested on:
CPython main branch
Operating systems tested on:
Linux
Linked PRs