Sync from SUSE:SLFO:Main python-urllib3_1 revision 9fad0e30969e0b982195f69c1a3e923a

This commit is contained in:
Adrian Schröter 2024-05-03 23:24:51 +02:00
commit c657c76557
7 changed files with 1572 additions and 0 deletions

23
.gitattributes vendored Normal file
View File

@ -0,0 +1,23 @@
## Default LFS
*.7z filter=lfs diff=lfs merge=lfs -text
*.bsp filter=lfs diff=lfs merge=lfs -text
*.bz2 filter=lfs diff=lfs merge=lfs -text
*.gem filter=lfs diff=lfs merge=lfs -text
*.gz filter=lfs diff=lfs merge=lfs -text
*.jar filter=lfs diff=lfs merge=lfs -text
*.lz filter=lfs diff=lfs merge=lfs -text
*.lzma filter=lfs diff=lfs merge=lfs -text
*.obscpio filter=lfs diff=lfs merge=lfs -text
*.oxt filter=lfs diff=lfs merge=lfs -text
*.pdf filter=lfs diff=lfs merge=lfs -text
*.png filter=lfs diff=lfs merge=lfs -text
*.rpm filter=lfs diff=lfs merge=lfs -text
*.tbz filter=lfs diff=lfs merge=lfs -text
*.tbz2 filter=lfs diff=lfs merge=lfs -text
*.tgz filter=lfs diff=lfs merge=lfs -text
*.ttf filter=lfs diff=lfs merge=lfs -text
*.txz filter=lfs diff=lfs merge=lfs -text
*.whl filter=lfs diff=lfs merge=lfs -text
*.xz filter=lfs diff=lfs merge=lfs -text
*.zip filter=lfs diff=lfs merge=lfs -text
*.zst filter=lfs diff=lfs merge=lfs -text

3
_multibuild Normal file
View File

@ -0,0 +1,3 @@
<multibuild>
<package>test</package>
</multibuild>

34
openssl-3.2.patch Normal file
View File

@ -0,0 +1,34 @@
Index: urllib3-1.26.18/changelog/3268.bugfix.rst
===================================================================
--- /dev/null
+++ urllib3-1.26.18/changelog/3268.bugfix.rst
@@ -0,0 +1 @@
+Fixed handling of OpenSSL 3.2.0 new error message for misconfiguring an HTTP proxy as HTTPS.
Index: urllib3-1.26.18/test/with_dummyserver/test_socketlevel.py
===================================================================
--- urllib3-1.26.18.orig/test/with_dummyserver/test_socketlevel.py
+++ urllib3-1.26.18/test/with_dummyserver/test_socketlevel.py
@@ -1226,7 +1226,8 @@ class TestSSL(SocketDummyServerTestCase)
self._start_server(socket_handler)
with HTTPSConnectionPool(self.host, self.port, ca_certs=DEFAULT_CA) as pool:
with pytest.raises(
- SSLError, match=r"(wrong version number|record overflow)"
+ SSLError,
+ match=r"(wrong version number|record overflow|record layer failure)",
):
pool.request("GET", "/", retries=False)
Index: urllib3-1.26.18/src/urllib3/connectionpool.py
===================================================================
--- urllib3-1.26.18.orig/src/urllib3/connectionpool.py
+++ urllib3-1.26.18/src/urllib3/connectionpool.py
@@ -768,7 +768,8 @@ class HTTPConnectionPool(ConnectionPool,
# so we try to cover our bases here!
message = " ".join(re.split("[^a-z]", str(ssl_error).lower()))
return (
- "wrong version number" in message or "unknown protocol" in message
+ "wrong version number" in message or "unknown protocol" in message or "record layer failure" in message
+
)
# Try to detect a common user error with proxies which is to

1098
python-urllib3_1.changes Normal file

File diff suppressed because it is too large Load Diff

150
python-urllib3_1.spec Normal file
View File

@ -0,0 +1,150 @@
#
# spec file
#
# Copyright (c) 2024 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via https://bugs.opensuse.org/
#
%global flavor @BUILD_FLAVOR@%{nil}
%if "%{flavor}" == "test"
%define psuffix -test
%bcond_without test
%else
%define psuffix %{nil}
%bcond_with test
%endif
%{?sle15_python_module_pythons}
Name: python-urllib3_1%{psuffix}
Version: 1.26.18
Release: 0
Summary: HTTP library with thread-safe connection pooling, file post, and more
License: MIT
Group: Development/Languages/Python
URL: https://urllib3.readthedocs.org/
Source: https://files.pythonhosted.org/packages/source/u/urllib3/urllib3-%{version}.tar.gz
# PATCH-FIX-UPSTREAM remove_mock.patch gh#urllib3/urllib3#2108 mcepl@suse.com
# remove dependency on the external module mock
Patch0: remove_mock.patch
# PATCH-FIX-UPSTREAM openssl-3.2.patch gh#urllib3/urllib3#3271
Patch1: openssl-3.2.patch
BuildRequires: %{python_module base >= 3.7}
BuildRequires: %{python_module pip}
BuildRequires: %{python_module setuptools}
BuildRequires: %{python_module six}
BuildRequires: %{python_module wheel}
BuildRequires: fdupes
BuildRequires: python-rpm-macros
#!BuildIgnore: python-requests
Requires: ca-certificates-mozilla
Requires: python-certifi
Requires: python-cryptography >= 1.3.4
Requires: python-idna >= 2.0.0
Requires: python-pyOpenSSL >= 0.14
Requires: python-six >= 1.12.0
Recommends: python-Brotli >= 1.0.9
Recommends: python-PySocks >= 1.5.6
BuildArch: noarch
%if %{with test}
BuildRequires: %{python_module Brotli >= 1.0.9}
BuildRequires: %{python_module PySocks >= 1.5.6}
BuildRequires: %{python_module dateutil}
BuildRequires: %{python_module flaky}
BuildRequires: %{python_module psutil}
BuildRequires: %{python_module pytest-freezegun}
BuildRequires: %{python_module pytest-timeout}
BuildRequires: %{python_module pytest}
BuildRequires: %{python_module python-dateutil}
BuildRequires: %{python_module tornado >= 6}
BuildRequires: %{python_module trustme >= 0.5.3}
BuildRequires: %{python_module urllib3_1 >= %{version}}
%endif
Provides: python-urllib3 = %{version}
Conflicts: python-urllib3 >= 2
%python_subpackages
%description
Highlights
- Re-use the same socket connection for multiple requests
(HTTPConnectionPool and HTTPSConnectionPool)
(with optional client-side certificate verification).
- File posting (encode_multipart_formdata).
- Built-in redirection and retries (optional).
- Supports gzip and deflate decoding.
- Thread-safe and sanity-safe.
- Works with AppEngine, gevent, and eventlib.
- Tested on Python 2.6+ and Python 3.3+, 100% unit test coverage.
- Small and easy to understand codebase perfect for extending and building upon.
For a more comprehensive solution, have a look at
Requests which is also powered by urllib3.
%prep
%autosetup -p1 -n urllib3-%{version}
find . -type f -exec chmod a-x '{}' \;
find . -name __pycache__ -type d -exec rm -fr {} +
# Drop the dummyserver tests, they fail in OBS
rm test/with_dummyserver/test_proxy_poolmanager.py
rm test/with_dummyserver/test_poolmanager.py
# Don't run the Google App Engine tests
rm -r test/appengine/
%build
%pyproject_wheel
%install
%if !%{with test}
%pyproject_install
%{python_expand # Unbundle six
rm %{buildroot}/%{$python_sitelib}/urllib3/packages/six.py
rm %{buildroot}/%{$python_sitelib}/urllib3/packages/__pycache__/six*.pyc
ln -s %{$python_sitelib}/six.py %{buildroot}/%{$python_sitelib}/urllib3/packages/six.py
ln -sf %{$python_sitelib}/__pycache__/six.cpython-%{$python_version_nodots}.opt-1.pyc \
%{buildroot}/%{$python_sitelib}/urllib3/packages/__pycache__/
ln -sf %{$python_sitelib}/__pycache__/six.cpython-%{$python_version_nodots}.pyc \
%{buildroot}/%{$python_sitelib}/urllib3/packages/__pycache__/
%fdupes %{buildroot}%{$python_sitelib}
}
%endif
%if %{with test}
%check
# gh#urllib3/urllib3#2109
export CI="true"
# skip some randomly failing tests (mostly on i586, but sometimes they fail on other architectures)
skiplist="test_ssl_read_timeout or test_ssl_failed_fingerprint_verification or test_ssl_custom_validation_failure_terminates"
# gh#urllib3/urllib3#1752 and others: upstream's way of checking that the build
# system has a correct system time breaks (re-)building the package after too
# many months have passed since the last release.
skiplist+=" or test_recent_date"
# too slow to run in obs (checks 2GiB of data)
skiplist+=" or test_requesting_large_resources_via_ssl"
# Python 3.12: SSL requests to localhost hang during handshake
python312_skip=" or TestClientCerts or TestSSL or test_cannot_import_ssl or (TestProxyManager and test_connect)"
%pytest -k "not (${skiplist} ${$python_skip})" --no-success-flaky-report
%endif
%if ! %{with test}
%files %{python_files}
%license LICENSE.txt
%doc CHANGES.rst README.rst
%{python_sitelib}/urllib3
%{python_sitelib}/urllib3-%{version}.dist-info
%endif
%changelog

261
remove_mock.patch Normal file
View File

@ -0,0 +1,261 @@
Index: urllib3-1.26.16/docs/conf.py
===================================================================
--- urllib3-1.26.16.orig/docs/conf.py
+++ urllib3-1.26.16/docs/conf.py
@@ -14,7 +14,10 @@ sys.path.insert(0, root_path)
# Mock some expensive/platform-specific modules so build will work.
# (https://read-the-docs.readthedocs.io/en/latest/faq.html#\
# i-get-import-errors-on-libraries-that-depend-on-c-modules)
-import mock
+try:
+ import unittest.mock as mock
+except ImportError:
+ import mock
class MockModule(mock.Mock):
Index: urllib3-1.26.16/test/contrib/test_pyopenssl.py
===================================================================
--- urllib3-1.26.16.orig/test/contrib/test_pyopenssl.py
+++ urllib3-1.26.16/test/contrib/test_pyopenssl.py
@@ -1,7 +1,10 @@
# -*- coding: utf-8 -*-
import os
-import mock
+try:
+ import unittest.mock as mock
+except ImportError:
+ import mock
import pytest
try:
Index: urllib3-1.26.16/test/contrib/test_pyopenssl_dependencies.py
===================================================================
--- urllib3-1.26.16.orig/test/contrib/test_pyopenssl_dependencies.py
+++ urllib3-1.26.16/test/contrib/test_pyopenssl_dependencies.py
@@ -1,6 +1,9 @@
# -*- coding: utf-8 -*-
import pytest
-from mock import Mock, patch
+try:
+ from unittest.mock import Mock, patch
+except ImportError:
+ from mock import Mock, patch
try:
from urllib3.contrib.pyopenssl import extract_from_urllib3, inject_into_urllib3
Index: urllib3-1.26.16/test/test_connection.py
===================================================================
--- urllib3-1.26.16.orig/test/test_connection.py
+++ urllib3-1.26.16/test/test_connection.py
@@ -1,6 +1,9 @@
import datetime
-import mock
+try:
+ import unittest.mock as mock
+except ImportError:
+ import mock
import pytest
from urllib3.connection import RECENT_DATE, CertificateError, _match_hostname
Index: urllib3-1.26.16/test/test_connectionpool.py
===================================================================
--- urllib3-1.26.16.orig/test/test_connectionpool.py
+++ urllib3-1.26.16/test/test_connectionpool.py
@@ -6,7 +6,10 @@ from ssl import SSLError as BaseSSLError
from test import SHORT_TIMEOUT
import pytest
-from mock import Mock
+try:
+ from unittest.mock import Mock
+except ImportError:
+ from mock import Mock
from dummyserver.server import DEFAULT_CA
from urllib3._collections import HTTPHeaderDict
Index: urllib3-1.26.16/test/test_queue_monkeypatch.py
===================================================================
--- urllib3-1.26.16.orig/test/test_queue_monkeypatch.py
+++ urllib3-1.26.16/test/test_queue_monkeypatch.py
@@ -1,6 +1,9 @@
from __future__ import absolute_import
-import mock
+try:
+ import unittest.mock as mock
+except ImportError:
+ import mock
import pytest
from urllib3 import HTTPConnectionPool
Index: urllib3-1.26.16/test/test_response.py
===================================================================
--- urllib3-1.26.16.orig/test/test_response.py
+++ urllib3-1.26.16/test/test_response.py
@@ -9,7 +9,10 @@ from base64 import b64decode
from io import BufferedReader, BytesIO, TextIOWrapper
from test import onlyBrotlipy
-import mock
+try:
+ import unittest.mock as mock
+except ImportError:
+ import mock
import pytest
import six
Index: urllib3-1.26.16/test/test_retry.py
===================================================================
--- urllib3-1.26.16.orig/test/test_retry.py
+++ urllib3-1.26.16/test/test_retry.py
@@ -1,6 +1,9 @@
import warnings
-import mock
+try:
+ import unittest.mock as mock
+except ImportError:
+ import mock
import pytest
from urllib3.exceptions import (
Index: urllib3-1.26.16/test/test_retry_deprecated.py
===================================================================
--- urllib3-1.26.16.orig/test/test_retry_deprecated.py
+++ urllib3-1.26.16/test/test_retry_deprecated.py
@@ -1,7 +1,10 @@
# This is a copy-paste of test_retry.py with extra asserts about deprecated options. It will be removed for v2.
import warnings
-import mock
+try:
+ import unittest.mock as mock
+except ImportError:
+ import mock
import pytest
from urllib3.exceptions import (
Index: urllib3-1.26.16/test/test_ssl.py
===================================================================
--- urllib3-1.26.16.orig/test/test_ssl.py
+++ urllib3-1.26.16/test/test_ssl.py
@@ -1,6 +1,9 @@
from test import notPyPy2
-import mock
+try:
+ import unittest.mock as mock
+except ImportError:
+ import mock
import pytest
from urllib3.exceptions import SNIMissingWarning
Index: urllib3-1.26.16/test/test_ssltransport.py
===================================================================
--- urllib3-1.26.16.orig/test/test_ssltransport.py
+++ urllib3-1.26.16/test/test_ssltransport.py
@@ -4,7 +4,10 @@ import socket
import ssl
import sys
-import mock
+try:
+ import unittest.mock as mock
+except ImportError:
+ import mock
import pytest
from dummyserver.server import DEFAULT_CA, DEFAULT_CERTS
Index: urllib3-1.26.16/test/test_util.py
===================================================================
--- urllib3-1.26.16.orig/test/test_util.py
+++ urllib3-1.26.16/test/test_util.py
@@ -9,7 +9,10 @@ from itertools import chain
from test import notBrotlipy, onlyBrotlipy, onlyPy2, onlyPy3
import pytest
-from mock import Mock, patch
+try:
+ from unittest.mock import Mock, patch
+except ImportError:
+ from mock import Mock, patch
from urllib3 import add_stderr_logger, disable_warnings, util
from urllib3.exceptions import (
Index: urllib3-1.26.16/test/with_dummyserver/test_connectionpool.py
===================================================================
--- urllib3-1.26.16.orig/test/with_dummyserver/test_connectionpool.py
+++ urllib3-1.26.16/test/with_dummyserver/test_connectionpool.py
@@ -12,7 +12,10 @@ import warnings
from test import LONG_TIMEOUT, SHORT_TIMEOUT, onlyPy2
from threading import Event
-import mock
+try:
+ import unittest.mock as mock
+except ImportError:
+ import mock
import pytest
import six
Index: urllib3-1.26.16/test/with_dummyserver/test_https.py
===================================================================
--- urllib3-1.26.16.orig/test/with_dummyserver/test_https.py
+++ urllib3-1.26.16/test/with_dummyserver/test_https.py
@@ -18,7 +18,10 @@ from test import (
resolvesLocalhostFQDN,
)
-import mock
+try:
+ import unittest.mock as mock
+except ImportError:
+ import mock
import pytest
import trustme
Index: urllib3-1.26.16/test/with_dummyserver/test_socketlevel.py
===================================================================
--- urllib3-1.26.16.orig/test/with_dummyserver/test_socketlevel.py
+++ urllib3-1.26.16/test/with_dummyserver/test_socketlevel.py
@@ -54,7 +54,10 @@ from test import (
)
from threading import Event
-import mock
+try:
+ import unittest.mock as mock
+except ImportError:
+ import mock
import pytest
import trustme
Index: urllib3-1.26.16/test/test_poolmanager.py
===================================================================
--- urllib3-1.26.16.orig/test/test_poolmanager.py
+++ urllib3-1.26.16/test/test_poolmanager.py
@@ -3,7 +3,11 @@ import socket
from test import resolvesLocalhostFQDN
import pytest
-from mock import patch
+
+try:
+ import unittest.mock as mock
+except ImportError:
+ import mock
from urllib3 import connection_from_url
from urllib3.exceptions import LocationValueError
@@ -361,7 +365,7 @@ class TestPoolManager(object):
"http://[a::b%25zone]",
],
)
- @patch("urllib3.util.connection.create_connection")
+ @mock.patch("urllib3.util.connection.create_connection")
def test_e2e_connect_to_ipv6_scoped(self, create_connection, url):
"""Checks that IPv6 scoped addresses are properly handled end-to-end.

BIN
urllib3-1.26.18.tar.gz (Stored with Git LFS) Normal file

Binary file not shown.