Workaround for a bug in Python 3.5 and 3.6 affecting UDP proxying #128
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
(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