This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author giampaolo.rodola
Recipients giampaolo.rodola
Date 2017-04-29.08:23:42
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1493454223.18.0.808565419105.issue30204@psf.upfronthosting.co.za>
In-reply-to
Content
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
History
Date User Action Args
2017-04-29 08:23:43giampaolo.rodolasetrecipients: + giampaolo.rodola
2017-04-29 08:23:43giampaolo.rodolasetmessageid: <1493454223.18.0.808565419105.issue30204@psf.upfronthosting.co.za>
2017-04-29 08:23:43giampaolo.rodolalinkissue30204 messages
2017-04-29 08:23:42giampaolo.rodolacreate