Christian Heimes added the comment:
I can still reproduce the issue with Python 3.9 and newer.
>>> import socket
>>> socket.socket(socket.AF_INET, socket.SOCK_STREAM).proto
0
--
type: -> behavior
versions: +Python 3.10, Python 3.11, Python 3.9 -Python 2.7, Python 3.5, Python
3.6
__
Martin Panter added the comment:
The documentation already says “Socket objects also have these (read-only)
attributes that correspond to the values given to the socket constructor. . . .
socket.proto”. For existing versions of Python, I’m not sure there is much else
we can do.
In Issue 27377
New submission from Christian Heimes:
The proto property of a socket object does not reflect the actual protocol of
the socket file descriptor:
>>> import socket
>>> SO_PROTOCOL = getattr(socket, 'SO_PROTOCOL', 38)
>>> tcp = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
>>> tcp.proto
0
>>>