[New-bugs-announce] [issue30204] socket.setblocking(0) changes socket.type
Giampaolo Rodola'
report at bugs.python.org
Sat Apr 29 04:23:43 EDT 2017
New submission from Giampaolo Rodola':
This caused me a lot of headaches (broken test) before figuring out what the heck was wrong: =)
>>> import socket
>>> s = socket.socket()
>>> s.type
<SocketKind.SOCK_STREAM: 1>
>>> s.setblocking(0)
>>> s.type
2049
>>> s.setblocking(1)
>>> s.type
<SocketKind.SOCK_STREAM: 1>
getsockopt() on the other hand always tells the truth:
>>> s.getsockopt(socket.SOL_SOCKET, socket.SO_TYPE)
1
...so I suppose we can do that in the "type" property of the Python socket class.
It appears the type is set in socket init:
https://github.com/python/cpython/blob/1e2147b9d75a64df370a9393c2b5b9d170dc0afd/Modules/socketmodule.c#L904
...and it's changed later in setblocking:
https://github.com/python/cpython/blob/1e2147b9d75a64df370a9393c2b5b9d170dc0afd/Modules/socketmodule.c#L609
----------
components: Library (Lib)
messages: 292576
nosy: giampaolo.rodola
priority: normal
severity: normal
status: open
title: socket.setblocking(0) changes socket.type
versions: Python 3.6, Python 3.7
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue30204>
_______________________________________
More information about the New-bugs-announce
mailing list