gh-135748: Use Argument Clinic for more socket functions - #155257
Open
serhiy-storchaka wants to merge 2 commits into
Open
gh-135748: Use Argument Clinic for more socket functions#155257serhiy-storchaka wants to merge 2 commits into
serhiy-storchaka wants to merge 2 commits into
Conversation
Convert all convertible functions and methods of the socket module. They now have signatures for introspection, and functions which take several arguments use METH_FASTCALL instead of METH_VARARGS. ioctl(), sendto() and setsockopt() are left as they are. Their behaviour depends on the number of the arguments or on the value of a preceding argument, which Argument Clinic cannot express.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Convert all convertible functions and methods of the socket module to Argument Clinic. They now have signatures for introspection, and functions which take several arguments use
METH_FASTCALLinstead ofMETH_VARARGS.The number of
_socketcallables for whichinspect.signature()fails drops from 26 to 7. Five of those seven are deliberate:listen()(the default isPy_MIN(SOMAXCONN, 128)),getservbyname()andgetservbyport()(the C default isNULLandNoneis not accepted),sendmsg()andsendmsg_afalg()(arguments which are absent rather than defaulted).ioctl(),sendto()andsetsockopt()are left as they are. Their behaviour depends on the number of the arguments or on the value of a preceding argument, which Argument Clinic cannot express:sendto(data[, flags], address)-- the optional argument is in the middle, while optional groups only support[left] required [right].setsockopt()distinguishes 3 from 4 arguments withPyTuple_Size(), and both resulting error messages are asserted bytest_socket.ioctl()parses its second argument differently depending oncmd.The parameter names are taken from the existing docstrings. Seven of them differ from
Doc/library/socket.rst(for examplerecv(buffersize)versus the documentedbufsize); the documentation is left unchanged here.