Skip to content

Conversation

@snemes
Copy link

@snemes snemes commented Aug 5, 2019

Python versions 3.5 and 3.6 have a nasty bug related to the socket type.

In these versions, the socket type is sometimes messed up and SOCK_DGRAM (2) becomes 2050.

$ python3
Python 3.6.8 (default, Jan 14 2019, 11:02:34) 
[GCC 8.0.1 20180414 (experimental) [trunk revision 259383]] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import socket
>>> sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
>>> sock.type
<SocketKind.SOCK_DGRAM: 2>
>>> sock.settimeout(0)
>>> sock.type
2050

(However sock.getsockopt(socket.SOL_SOCKET, socket.SO_TYPE) still works as expected and returns the value 2.)

This unfortunately breaks the comparisons with socket.SOCK_DGRAM and makes it impossible to send UDP data through proxies (via UDPASSOCIATE/UDPREPLY). This pull request is intended to fix that, but otherwise does not change functionality. Apparently this Python bug has also been fixed in Python 3.7, but some users of PySocks might also got stuck to older versions, so this might be useful for them.

This Python bug is also briefly described in https://bugs.python.org/issue19422 (this exact issue is slightly unrelated, but triggers the same Python bug)
In Python 3.7, this was fixed in https://bugs.python.org/issue32331 / python/cpython#4877

@yuchting
Copy link

where is @Anorov ?
Please accept this RP.

@molangning
Copy link

No Anorov, Just me :)

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