HTTPretty: Python 3.7 test failures (SSL related)
https://travis-ci.org/hroncok/HTTPretty/jobs/381122886
AssertionError: Traceback (most recent call last):
File "/opt/python/3.7-dev/lib/python3.7/urllib/request.py", line 1316, in do_open
encode_chunked=req.has_header('Transfer-encoding'))
File "/opt/python/3.7-dev/lib/python3.7/http/client.py", line 1229, in request
self._send_request(method, url, body, headers, encode_chunked)
File "/opt/python/3.7-dev/lib/python3.7/http/client.py", line 1275, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "/opt/python/3.7-dev/lib/python3.7/http/client.py", line 1224, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "/opt/python/3.7-dev/lib/python3.7/http/client.py", line 1016, in _send_output
self.send(msg)
File "/opt/python/3.7-dev/lib/python3.7/http/client.py", line 977, in send
self.sock.sendall(data)
File "/opt/python/3.7-dev/lib/python3.7/ssl.py", line 987, in sendall
return socket.sendall(self, data, flags)
BrokenPipeError: [Errno 32] Broken pipe
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/travis/virtualenv/python3.7-dev/lib/python3.7/site-packages/sure/__init__.py", line 186, in wrap
func(start, *args, **kw)
File "/home/travis/build/hroncok/HTTPretty/tests/functional/test_urllib2.py", line 191, in test_httpretty_should_support_a_list_of_successive_responses_urllib2
request1 = urlopen('https://api.yahoo.com/test')
File "/opt/python/3.7-dev/lib/python3.7/urllib/request.py", line 222, in urlopen
return opener.open(url, data, timeout)
File "/opt/python/3.7-dev/lib/python3.7/urllib/request.py", line 525, in open
response = self._open(req, data)
File "/opt/python/3.7-dev/lib/python3.7/urllib/request.py", line 543, in _open
'_open', req)
File "/opt/python/3.7-dev/lib/python3.7/urllib/request.py", line 503, in _call_chain
result = func(*args)
File "/opt/python/3.7-dev/lib/python3.7/urllib/request.py", line 1359, in https_open
context=self._context, check_hostname=self._check_hostname)
File "/opt/python/3.7-dev/lib/python3.7/urllib/request.py", line 1318, in do_open
raise URLError(err)
https://travis-ci.org/hroncok/HTTPretty/jobs/381122887
Traceback (most recent call last):
/home/travis/virtualenv/python3.7-dev/lib/python3.7/site-packages/nose/case.py line 198 in runTest
self.test(*self.arg)
httpretty/core.py line 1631 in wrapper
return test(*args, **kw)
tests/pyopenssl/test_mock.py line 42 in test_httpretty_overrides_when_pyopenssl_installed
response = requests.get('https://yipit.com')
/home/travis/virtualenv/python3.7-dev/lib/python3.7/site-packages/requests/api.py line 72 in get
return request('get', url, params=params, **kwargs)
/home/travis/virtualenv/python3.7-dev/lib/python3.7/site-packages/requests/api.py line 58 in request
return session.request(method=method, url=url, **kwargs)
/home/travis/virtualenv/python3.7-dev/lib/python3.7/site-packages/requests/sessions.py line 508 in request
resp = self.send(prep, **send_kwargs)
/home/travis/virtualenv/python3.7-dev/lib/python3.7/site-packages/requests/sessions.py line 618 in send
r = adapter.send(request, **kwargs)
/home/travis/virtualenv/python3.7-dev/lib/python3.7/site-packages/requests/adapters.py line 506 in send
raise SSLError(e, request=request)
SSLError: HTTPSConnectionPool(host='yipit.com', port=443): Max retries exceeded with url: / (Caused by SSLError(CertificateError("wildcard can only be present in the leftmost segment: '*yipit.com'")))
Also with Python 3.7.0b4 on Fedora:
AssertionError: Traceback (most recent call last):
File "/home/churchyard/Dokumenty/RedHat/HTTPretty/.tox/py37/lib/python3.7/site-packages/sure/__init__.py", line 186, in wrap
func(start, *args, **kw)
File "/home/churchyard/Dokumenty/RedHat/HTTPretty/tests/functional/test_httplib2.py", line 278, in test_callback_response
'https://api.yahoo.com/test', 'GET')
File "/home/churchyard/Dokumenty/RedHat/HTTPretty/.tox/py37/lib/python3.7/site-packages/httplib2/__init__.py", line 1514, in request
(response, content) = self._request(conn, authority, uri, request_uri, method, body, headers, redirections, cachekey)
File "/home/churchyard/Dokumenty/RedHat/HTTPretty/.tox/py37/lib/python3.7/site-packages/httplib2/__init__.py", line 1264, in _request
(response, content) = self._conn_request(conn, request_uri, method, body, headers)
File "/home/churchyard/Dokumenty/RedHat/HTTPretty/.tox/py37/lib/python3.7/site-packages/httplib2/__init__.py", line 1187, in _conn_request
conn.connect()
File "/home/churchyard/Dokumenty/RedHat/HTTPretty/.tox/py37/lib/python3.7/site-packages/httplib2/__init__.py", line 1013, in connect
self.sock = self._context.wrap_socket(sock, server_hostname=self.host)
File "/usr/lib64/python3.7/ssl.py", line 412, in wrap_socket
session=session
File "/usr/lib64/python3.7/ssl.py", line 817, in _create
super(SSLSocket, self).__init__(**kwargs)
TypeError: super(type, obj): obj must be an instance or subtype of type
But fallbacks to broken pipe above if I do crazy changes in SSLSocket from the stdlib.
cc @tiran because I have no idea what’s going on here.
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 20 (11 by maintainers)
Commits related to this issue
- Python 3.7 support: Monkeypatch ssl.SSLContext.wrap_socket as well The ssl module changed a bit in 3.7 and this is needed now. Doesn't break older Python versions. See https://github.com/gabrielfalc... — committed to hroncok/HTTPretty by hroncok 6 years ago
- Python 3.7 support: re.Pattern is the new class for re patterns See https://github.com/gabrielfalcao/HTTPretty/issues/337 — committed to hroncok/HTTPretty by hroncok 6 years ago
- Python 3.7 support: Partial wild card matching is no longer supported See https://github.com/gabrielfalcao/HTTPretty/issues/337 — committed to hroncok/HTTPretty by hroncok 6 years ago
- Python 3.7 support (#339) * Python 3.7 support: Monkeypatch ssl.SSLContext.wrap_socket as well The ssl module changed a bit in 3.7 and this is needed now. Doesn't break older Python versions. ... — committed to gabrielfalcao/HTTPretty by hroncok 6 years ago
- Support old Python 2.7 releases See https://github.com/gabrielfalcao/HTTPretty/issues/337#issuecomment-395481459https://github.com/gabrielfalcao/HTTPretty/issues/337#issuecomment-395481459 — committed to hroncok/HTTPretty by hroncok 6 years ago
- Support old Python 2.7 releases See https://github.com/gabrielfalcao/HTTPretty/issues/337#issuecomment-395481459https://github.com/gabrielfalcao/HTTPretty/issues/337#issuecomment-395481459 — committed to hroncok/HTTPretty by hroncok 6 years ago
- Support old Python 2.7 releases (#341) See https://github.com/gabrielfalcao/HTTPretty/issues/337#issuecomment-395481459https://github.com/gabrielfalcao/HTTPretty/issues/337#issuecomment-395481459 — committed to gabrielfalcao/HTTPretty by hroncok 6 years ago
- Send SNI for HTTPS connections Several Google servers, including storage.googleapis.com, send an invalid certificate in response to HTTPS connections which do not include Server Name Indication (SNI)... — committed to boto/boto by kevinoid 5 years ago
@elafontaine Does https://github.com/gabrielfalcao/HTTPretty/pull/341 help?
I’ve tested with 2.7.15 actually.
See https://github.com/gabrielfalcao/HTTPretty/pull/339
I am working on this and I think I’ve got it covered.
The root cause of the issue is inside the exception chain, although a bit hard to spot:
Starting with Python 3.7, partial wild card matching is no longer supported. Browsers have removed support for partial wild cards a while ago. See https://docs.python.org/3.7/library/ssl.html#ssl.match_hostname and https://docs.python.org/3.7/whatsnew/3.7.html#ssl