Raise an unretryable exception when ssl module isn't available
MODIFY
src/urllib3/connectionpool.py
src/urllib3/connectionpool.py
@@ -1020,7 +1020,7 @@ class HTTPSConnectionPool(HTTPConnectionPool):
)
if not self.ConnectionCls or self.ConnectionCls is DummyConnection: # type: ignore[comparison-overlap]
- raise SSLError(
+ raise ImportError(
"Can't connect to HTTPS URL because the SSL module is not available."
)

MODIFY
test/with_dummyserver/test_https.py
test/with_dummyserver/test_https.py
@@ -376,11 +376,10 @@ class TestHTTPS(HTTPSDummyServerTestCase):
def test_no_ssl(self) -> None:
with HTTPSConnectionPool(self.host, self.port) as pool:
pool.ConnectionCls = None # type: ignore[assignment]
- with pytest.raises(SSLError):
+ with pytest.raises(ImportError):
pool._new_conn()
- with pytest.raises(MaxRetryError) as cm:
+ with pytest.raises(ImportError):
pool.request("GET", "/", retries=0)
- assert isinstance(cm.value.reason, SSLError)
def test_unverified_ssl(self) -> None:
"""Test that bare HTTPSConnection can connect, make requests"""

Raise an unretryable exception when ssl module isn't available