From 3befec9d5c467e3d5d542844fde52aec112a7013 Mon Sep 17 00:00:00 2001 From: Adam Williamson Date: Nov 19 2021 20:36:12 +0000 Subject: Fix Retry allowed methods for urllib 1.25 (F34 and earlier) This is an urgent backport as it turns out 2.1.5 is broken on F34 and earlier. Sorry about that. --- diff --git a/0001-Fix-Retry-allowed-methods-for-urllib-1.25.patch b/0001-Fix-Retry-allowed-methods-for-urllib-1.25.patch new file mode 100644 index 0000000..011be8c --- /dev/null +++ b/0001-Fix-Retry-allowed-methods-for-urllib-1.25.patch @@ -0,0 +1,43 @@ +From 1bc06edb40e4f46f0ab2bdc90aefc4bca7089051 Mon Sep 17 00:00:00 2001 +From: Adam Williamson +Date: Fri, 19 Nov 2021 11:32:12 -0800 +Subject: [PATCH] Fix Retry allowed methods for urllib 1.25 + +This is a follow-up to ae4a3a6. It seems urllib devs went with a +*really* aggressive deprecation schedule here - the kwarg +name they deprecated in 1.26 does not exist in 1.25, which is +still shipped in Fedora 34 (and probably many other stable +distros). If you want the code to work on both 1.25 and 1.26 +without any deprecation warnings, you need to fudge it like +this. Inspired by +https://github.com/firebase/firebase-admin-python/pull/532 . + +Signed-off-by: Adam Williamson +--- + resultsdb_api.py | 6 +++++- + 1 file changed, 5 insertions(+), 1 deletion(-) + +diff --git a/resultsdb_api.py b/resultsdb_api.py +index 4b4e5e9..6705b47 100644 +--- a/resultsdb_api.py ++++ b/resultsdb_api.py +@@ -129,11 +129,15 @@ class ResultsDBapi(object): + self.request_auth = request_auth + + allowed_methods = list(Retry.DEFAULT_ALLOWED_METHODS) + ["POST"] ++ if hasattr(Retry.DEFAULT, "allowed_methods"): ++ _allow_args = {"allowed_methods": allowed_methods} ++ else: ++ _allow_args = {"method_whitelist": allowed_methods} + self._retry = Retry( + total=max_retries, + backoff_factor=backoff_factor, + status_forcelist=(500, 502, 503, 504), +- allowed_methods=allowed_methods ++ **_allow_args + ) + self._adapter = HTTPAdapter(max_retries=self._retry) + self.session = _ResultsDBSession() +-- +2.33.1 + diff --git a/python-resultsdb_api.spec b/python-resultsdb_api.spec index ad7dd0e..952ed93 100644 --- a/python-resultsdb_api.spec +++ b/python-resultsdb_api.spec @@ -1,7 +1,7 @@ Name: python-resultsdb_api # NOTE: if you update version, *make sure* to also update `setup.py` Version: 2.1.5 -Release: 1%{?dist} +Release: 2%{?dist} Summary: Interface api to ResultsDB License: GPLv2+ @@ -9,6 +9,10 @@ URL: https://pagure.io/taskotron/resultsdb_api Source0: https://qa.fedoraproject.org/releases/resultsdb_api/resultsdb_api-%{version}.tar.gz Patch0: 0001-Revert-Drop-Python-2-string-type-blob.patch +# https://pagure.io/taskotron/resultsdb_api/pull-request/14 +# Fixes a bug that broke things completely on F<=34 +Patch1: 0001-Fix-Retry-allowed-methods-for-urllib-1.25.patch + BuildArch: noarch %global _description\ @@ -103,6 +107,9 @@ BuildRequires: python3-virtualenv %endif %changelog +* Fri Nov 19 2021 Adam Williamson - 2.1.5-2 +- Fix Retry allowed methods for urllib 1.25 (F34 and earlier) + * Sun Nov 14 2021 Frantisek Zatloukal - 2.1.5-1 - Drop use of deprecated Retry parameter - Drop unnecessary `_KEEP` and just `None` instead