Skip to content

Conversation

@Rosuav
Copy link
Contributor

@Rosuav Rosuav commented Nov 21, 2025

Add the socket.IPV6_HDRINCL constant on platforms that support it.

There are a lot more constants that could also be added. How far should this be taken?


📚 Documentation preview 📚: https://cpython-previews--141818.org.readthedocs.build/

Copy link
Member

@vstinner vstinner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Rosuav and others added 2 commits November 22, 2025 00:57
…v5LdB.rst

Co-authored-by: Victor Stinner <vstinner@python.org>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
@Rosuav
Copy link
Contributor Author

Rosuav commented Nov 21, 2025

There are a bunch more constants not currently in the socket module. I made a list here: https://discuss.python.org/t/adding-new-socket-options-specifically-socket-ipv6-hdrincl/104964/2 Do we want to add more?

@picnixz
Copy link
Member

picnixz commented Nov 21, 2025

Looking at the constants that were found, I think all IP_* constants and IPV6_* constants could be added. However, I wonder how useful this can be. Are these constants usable as is by our interface or is there some pre-requirements that need to be met? (maybe the constant exists but requires some additional headers, etc).

@Rosuav
Copy link
Contributor Author

Rosuav commented Nov 21, 2025

However, I wonder how useful this can be.

The script retains #if and comments in case they're indicative, and in some cases, I believe those do indeed show that the constants aren't useful. (One of them, __SOCK_SIZE__, is clearly a false positive.) A lot of them are socket options or the values for them, so you could use them with setsockopt(). Some are factual notes (IN_LOOPBACKNET and the IN_CLASS* constants), could take 'em or leave 'em, not a lot to judge either way.

I'd be inclined to include all of the socket option flags, since they can be useful without any additional support. Most of them get/set integers (in a lot of cases, they're just booleans), and even the ones that aren't, there's ways to use those in Python without help.

I've no idea what IPV6_FL_* and IPV6_TLV_* are all about, so we could omit those until such time as someone asks about them.

@vstinner vstinner merged commit f21ed37 into python:main Nov 22, 2025
46 checks passed
@vstinner
Copy link
Member

PR merged, thank you.

@vstinner
Copy link
Member

There are a bunch more constants not currently in the socket module. I made a list here: https://discuss.python.org/t/adding-new-socket-options-specifically-socket-ipv6-hdrincl/104964/2 Do we want to add more?

I replied there: https://discuss.python.org/t/adding-new-socket-options-specifically-socket-ipv6-hdrincl/104964/5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants