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 <rep...@bugs.python.org>
<http://bugs.python.org/issue30204>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to