14
0

- Do not ignore deprecation warnings, the testsuite explicitly

clears all warnings multiple times.
- Add patch filter-pyopenssl-deprecationwarning.patch:
  * Explicitly filter out new DeprecationWarnings raised by PyOpenSSL 25.1+

OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-urllib3_1?expand=0&rev=30
This commit is contained in:
2025-08-05 06:00:05 +00:00
committed by Git OBS Bridge
parent 1fcdf21db8
commit 45e3606cd4
3 changed files with 144 additions and 3 deletions

View File

@@ -0,0 +1,133 @@
Index: urllib3-1.26.20/test/with_dummyserver/test_https.py
===================================================================
--- urllib3-1.26.20.orig/test/with_dummyserver/test_https.py
+++ urllib3-1.26.20/test/with_dummyserver/test_https.py
@@ -215,6 +215,10 @@ class TestHTTPS(HTTPSDummyServerTestCase
assert conn.__class__ == VerifiedHTTPSConnection
with warnings.catch_warnings(record=True) as w:
+ # Filter PyOpenSSL 25.1+ DeprecationWarning
+ warnings.filterwarnings(
+ "ignore", message="Attempting to mutate a Context after", category=DeprecationWarning
+ )
r = https_pool.request("GET", "/")
assert r.status == 200
@@ -245,6 +249,13 @@ class TestHTTPS(HTTPSDummyServerTestCase
r = https_pool.request("GET", "/")
assert r.status == 200
+ # Filter PyOpenSSL 25.1+ DeprecationWarning
+ calls = warn.call_args_list
+ calls = [
+ call for call in calls if call[0][1] != DeprecationWarning and
+ not call[0][0].startswith("Attempting to mutate a Context")
+ ]
+
# Modern versions of Python, or systems using PyOpenSSL, don't
# emit warnings.
if (
@@ -252,7 +263,7 @@ class TestHTTPS(HTTPSDummyServerTestCase
or util.IS_PYOPENSSL
or util.IS_SECURETRANSPORT
):
- assert not warn.called, warn.call_args_list
+ assert not calls
else:
assert warn.called
if util.HAS_SNI:
@@ -274,6 +285,13 @@ class TestHTTPS(HTTPSDummyServerTestCase
r = https_pool.request("GET", "/")
assert r.status == 200
+ # Filter PyOpenSSL 25.1+ DeprecationWarning
+ calls = warn.call_args_list
+ calls = [
+ call for call in calls if call[0][1] != DeprecationWarning and
+ not call[0][0].startswith("Attempting to mutate a Context")
+ ]
+
# Modern versions of Python, or systems using PyOpenSSL, don't
# emit warnings.
if (
@@ -281,7 +299,7 @@ class TestHTTPS(HTTPSDummyServerTestCase
or util.IS_PYOPENSSL
or util.IS_SECURETRANSPORT
):
- assert not warn.called, warn.call_args_list
+ assert not calls
else:
assert warn.called
if util.HAS_SNI:
@@ -306,6 +324,10 @@ class TestHTTPS(HTTPSDummyServerTestCase
assert conn.__class__ == VerifiedHTTPSConnection
with warnings.catch_warnings(record=True) as w:
+ # Filter PyOpenSSL 25.1+ DeprecationWarning
+ warnings.filterwarnings(
+ "ignore", message="Attempting to mutate a Context after", category=DeprecationWarning
+ )
r = https_pool.request("GET", "/")
assert r.status == 200
@@ -412,6 +434,12 @@ class TestHTTPS(HTTPSDummyServerTestCase
# warnings, which we want to ignore here.
calls = warn.call_args_list
+ # Filter PyOpenSSL 25.1+ DeprecationWarning
+ calls = [
+ call for call in calls if call[0][1] != DeprecationWarning and
+ not call[0][0].startswith("Attempting to mutate a Context")
+ ]
+
# If we're using a deprecated TLS version we can remove 'DeprecationWarning'
if self.tls_protocol_deprecated():
calls = [call for call in calls if call[0][1] != DeprecationWarning]
@@ -687,6 +715,11 @@ class TestHTTPS(HTTPSDummyServerTestCase
def _request_without_resource_warnings(self, method, url):
with warnings.catch_warnings(record=True) as w:
warnings.simplefilter("always")
+ # Filter PyOpenSSL 25.1+ DeprecationWarning
+ warnings.filterwarnings(
+ "ignore", message="Attempting to mutate a Context after",
+ category=DeprecationWarning
+ )
with HTTPSConnectionPool(
self.host, self.port, ca_certs=DEFAULT_CA
) as https_pool:
@@ -742,6 +775,11 @@ class TestHTTPS(HTTPSDummyServerTestCase
conn = https_pool._get_conn()
try:
with warnings.catch_warnings(record=True) as w:
+ # Filter PyOpenSSL 25.1+ DeprecationWarning
+ warnings.filterwarnings(
+ "ignore", message="Attempting to mutate a Context after",
+ category=DeprecationWarning
+ )
conn.connect()
if not hasattr(conn.sock, "version"):
pytest.skip("SSLSocket.version() not available")
@@ -769,6 +807,11 @@ class TestHTTPS(HTTPSDummyServerTestCase
conn = https_pool._get_conn()
try:
with warnings.catch_warnings(record=True) as w:
+ # Filter PyOpenSSL 25.1+ DeprecationWarning
+ warnings.filterwarnings(
+ "ignore", message="Attempting to mutate a Context after",
+ category=DeprecationWarning
+ )
conn.connect()
finally:
conn.close()
@@ -788,6 +831,11 @@ class TestHTTPS(HTTPSDummyServerTestCase
conn = https_pool._get_conn()
try:
with warnings.catch_warnings(record=True) as w:
+ # Filter PyOpenSSL 25.1+ DeprecationWarning
+ warnings.filterwarnings(
+ "ignore", message="Attempting to mutate a Context after",
+ category=DeprecationWarning
+ )
conn.connect()
finally:
conn.close()

View File

@@ -1,3 +1,11 @@
-------------------------------------------------------------------
Tue Aug 5 05:58:09 UTC 2025 - Steve Kowalik <steven.kowalik@suse.com>
- Do not ignore deprecation warnings, the testsuite explicitly
clears all warnings multiple times.
- Add patch filter-pyopenssl-deprecationwarning.patch:
* Explicitly filter out new DeprecationWarnings raised by PyOpenSSL 25.1+
-------------------------------------------------------------------
Thu Jul 17 20:28:07 UTC 2025 - Dirk Müller <dmueller@suse.com>

View File

@@ -1,7 +1,7 @@
#
# spec file for package python-urllib3_1
#
# Copyright (c) 2025 SUSE LLC
# Copyright (c) 2025 SUSE LLC and contributors
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@@ -37,6 +37,8 @@ Source: https://files.pythonhosted.org/packages/source/u/urllib3/urllib3
Patch0: remove_mock.patch
# PATCH-FIX-UPSTREAM CVE-2025-50181 gh#urllib3/urllib3@f05b1329126d, bsc#1244925
Patch1: CVE-2025-50181-poolmanager-redirects.patch
# PATCH-FIX-OPENSUSE Explicitly ignore new DeprecationWarning from PyOpenSSL 25.1+
Patch2: filter-pyopenssl-deprecationwarning.patch
BuildRequires: %{python_module base >= 3.7}
BuildRequires: %{python_module pip}
BuildRequires: %{python_module setuptools}
@@ -123,8 +125,6 @@ ln -sf %{$python_sitelib}/__pycache__/six.cpython-%{$python_version_nodots}.pyc
%if %{with test}
%check
export PYTEST_ADDOPTS="-W ignore::DeprecationWarning"
# gh#urllib3/urllib3#2109
export CI="true"
# skip some randomly failing tests (mostly on i586, but sometimes they fail on other architectures)