Message 271419 - Python tracker (original) (raw)

I got this stacktrace: File "test_ssl.py", line 3, in sock = ssl.SSLSocket(server_hostname="docs.python.org") File "/usr/lib/python3.4/ssl.py", line 536, in init if sock.getsockopt(SOL_SOCKET, SO_TYPE) != SOCK_STREAM: AttributeError: 'NoneType' object has no attribute 'getsockopt'

with this minimal code: import ssl

sock = ssl.SSLSocket(server_hostname="docs.python.org") sock.connect(("docs.python.org", 443)) sock.sendall(b"GET /3/library/ssl.html HTTP/1.0\r\nHost: docs.python.org\r\n\r\n") print(sock.recv(4096).decode())

Whereas the None socket is correctly handled a few lines later: https://hg.python.org/cpython/file/tip/Lib/ssl.py#l715

All Python >= 3.3 are affected (since https://hg.python.org/cpython/rev/a00842b783cf) and can be patched with the same file, attached to this issue.