summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichał Górny <mgorny@gentoo.org>2024-02-16 18:05:00 +0100
committerMichał Górny <mgorny@gentoo.org>2024-02-16 18:15:52 +0100
commitc886664d717e65f9496d9fdb31e71f89d4ad5e98 (patch)
tree4fbe07bfbe087d9af09ab4087aab7a64d56ed4c2 /dev-python/urllib3
parentdev-python/github3-py: Deselect failing tests (upstream did too) (diff)
downloadgentoo-c886664d717e65f9496d9fdb31e71f89d4ad5e98.tar.gz
gentoo-c886664d717e65f9496d9fdb31e71f89d4ad5e98.tar.bz2
gentoo-c886664d717e65f9496d9fdb31e71f89d4ad5e98.zip
dev-python/urllib3: Backport an upstream revert to fix regressions
Closes: https://bugs.gentoo.org/924333 Signed-off-by: Michał Górny <mgorny@gentoo.org>
Diffstat (limited to 'dev-python/urllib3')
-rw-r--r--dev-python/urllib3/files/urllib3-2.2.0-revert.patch42
-rw-r--r--dev-python/urllib3/urllib3-2.2.0-r1.ebuild (renamed from dev-python/urllib3/urllib3-2.2.0.ebuild)5
2 files changed, 47 insertions, 0 deletions
diff --git a/dev-python/urllib3/files/urllib3-2.2.0-revert.patch b/dev-python/urllib3/files/urllib3-2.2.0-revert.patch
new file mode 100644
index 000000000000..14175ecec58b
--- /dev/null
+++ b/dev-python/urllib3/files/urllib3-2.2.0-revert.patch
@@ -0,0 +1,42 @@
+From 49b2ddaf07ec9ef65ef12d0218117f20e739ee6e Mon Sep 17 00:00:00 2001
+From: Quentin Pradet <quentin.pradet@gmail.com>
+Date: Fri, 16 Feb 2024 11:35:30 +0400
+Subject: [PATCH] Stop casting request headers to HTTPHeaderDict (#3344)
+
+While this was done to fix a mypy error, we did not notice the
+consequences:
+
+ * This breaks boto3 that subclasses HTTPConnection because
+ HTTPHeaderDict does not support bytes values yet.
+ * When proxying, headers are still a dictionary by default.
+
+We can decide to reintroduce a forced conversion to HTTPHeaderDict in
+urllib3 3.0 if the above issues are fixed.
+---
+ changelog/3343.bugfix.rst | 1 +
+ src/urllib3/connectionpool.py | 4 ++--
+ 2 files changed, 3 insertions(+), 2 deletions(-)
+ create mode 100644 changelog/3343.bugfix.rst
+
+diff --git a/changelog/3343.bugfix.rst b/changelog/3343.bugfix.rst
+new file mode 100644
+index 0000000000..4f2df9e7a4
+--- /dev/null
++++ b/changelog/3343.bugfix.rst
+@@ -0,0 +1 @@
++Fixed ``HTTPConnectionPool.urlopen`` to stop automatically casting non-proxy headers to ``HTTPHeaderDict``. This change was premature as it did not apply to proxy headers and ``HTTPHeaderDict`` does not handle byte header values correctly yet.
+diff --git a/src/urllib3/connectionpool.py b/src/urllib3/connectionpool.py
+index 1036f0d718..bd58ff14dd 100644
+--- a/src/urllib3/connectionpool.py
++++ b/src/urllib3/connectionpool.py
+@@ -751,8 +751,8 @@ def urlopen( # type: ignore[override]
+ # have to copy the headers dict so we can safely change it without those
+ # changes being reflected in anyone else's copy.
+ if not http_tunnel_required:
+- headers = HTTPHeaderDict(headers)
+- headers.update(self.proxy_headers)
++ headers = headers.copy() # type: ignore[attr-defined]
++ headers.update(self.proxy_headers) # type: ignore[union-attr]
+
+ # Must keep the exception bound to a separate variable or else Python 3
+ # complains about UnboundLocalError.
diff --git a/dev-python/urllib3/urllib3-2.2.0.ebuild b/dev-python/urllib3/urllib3-2.2.0-r1.ebuild
index eb55415eb52a..bdcc50c7b073 100644
--- a/dev-python/urllib3/urllib3-2.2.0.ebuild
+++ b/dev-python/urllib3/urllib3-2.2.0-r1.ebuild
@@ -66,6 +66,11 @@ BDEPEND="
"
src_prepare() {
+ local PATCHES=(
+ # https://github.com/urllib3/urllib3/commit/49b2ddaf07ec9ef65ef12d0218117f20e739ee6e
+ "${FILESDIR}/${P}-revert.patch"
+ )
+
# upstream considers 0.5 s to be "long" for a timeout
# we get tons of test failures on *fast* systems because of that
sed -i -e '/LONG_TIMEOUT/s:0.5:5:' test/__init__.py || die