Skip to content

Commit

Permalink
Update python-CacheControl to version 0.12.11 / rev 12 via SR 1089718
Browse files Browse the repository at this point in the history
https://build.opensuse.org/request/show/1089718
by user dgarcia + dimstar_suse
- Add requests-fix.patch to support latest version of urllib3 and
  requests
  gh#psf/cachecontrol#301, gh#psf/cachecontrol#304
  • Loading branch information
dgarcia authored and bmwiedemann committed May 30, 2023
1 parent c1c2d7b commit 9402475
Show file tree
Hide file tree
Showing 5 changed files with 123 additions and 3 deletions.
Binary file modified packages/p/python-CacheControl/.files
Binary file not shown.
11 changes: 11 additions & 0 deletions packages/p/python-CacheControl/.rev
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,15 @@
<comment></comment>
<requestid>1085439</requestid>
</revision>
<revision rev="12" vrev="3">
<srcmd5>9dfdb55608695ada3f3164654a5d0909</srcmd5>
<version>0.12.11</version>
<time>1685476960</time>
<user>dimstar_suse</user>
<comment>- Add requests-fix.patch to support latest version of urllib3 and
requests
gh#ionrock/cachecontrol#301, gh#ionrock/cachecontrol#304
</comment>
<requestid>1089718</requestid>
</revision>
</revisionlist>
7 changes: 7 additions & 0 deletions packages/p/python-CacheControl/python-CacheControl.changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
-------------------------------------------------------------------
Tue May 30 07:53:24 UTC 2023 - Daniel Garcia <daniel.garcia@suse.com>

- Add requests-fix.patch to support latest version of urllib3 and
requests
gh#ionrock/cachecontrol#301, gh#ionrock/cachecontrol#304

-------------------------------------------------------------------
Mon May 8 06:37:48 UTC 2023 - Johannes Kastl <kastl@b1-systems.de>

Expand Down
14 changes: 11 additions & 3 deletions packages/p/python-CacheControl/python-CacheControl.spec
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@ License: Apache-2.0
Group: Development/Languages/Python
URL: https://github.com/ionrock/cachecontrol
Source: https://github.com/ionrock/cachecontrol/archive/v%{version}.tar.gz#/CacheControl-%{version}.tar.gz
# PATCH-FIX-UPSTREAM requests-fix.patch -- gh#ionrock/cachecontrol#301, gh#ionrock/cachecontrol#304
Patch0: requests-fix.patch
BuildRequires: %{python_module pip}
BuildRequires: %{python_module setuptools}
BuildRequires: %{python_module wheel}
BuildRequires: fdupes
BuildRequires: python-rpm-macros
Requires: python-msgpack >= 0.5.2
Expand All @@ -51,14 +55,18 @@ CacheControl is a port of the caching algorithms in httplib2 for use with
requests session object.

%prep
%setup -q -n cachecontrol-%{version}
%autosetup -p1 -n cachecontrol-%{version}
sed -i -e 's/^from mock/from unittest.mock/' -e 's/^import mock/from unittest import mock/' tests/*.py

%build
%python_build
%pyproject_wheel

%install
%python_install
%pyproject_install

# do not pack tests
%python_expand rm -rf %{buildroot}%{$python_sitelib}/tests

%python_clone -a %{buildroot}%{_bindir}/doesitcache
%python_expand %fdupes %{buildroot}%{$python_sitelib}

Expand Down
94 changes: 94 additions & 0 deletions packages/p/python-CacheControl/requests-fix.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
Index: cachecontrol-0.12.12/.github/workflows/tests.yml
===================================================================
--- cachecontrol-0.12.12.orig/.github/workflows/tests.yml
+++ cachecontrol-0.12.12/.github/workflows/tests.yml
@@ -14,9 +14,15 @@ jobs:
runs-on: "${{ matrix.os }}"

strategy:
+ fail-fast: false
matrix:
- python-version: ["3.6", "3.7", "3.8", "3.9", "3.10"]
- os: ["macos-10.15", "windows-latest", "ubuntu-latest"]
+ python-version: ["3.7", "3.8", "3.9", "3.10"]
+ os: ["macos-latest", "windows-latest", "ubuntu-latest"]
+ include:
+ - python-version: "3.6"
+ os: "ubuntu-20.04"
+ - python-version: "3.6"
+ os: "windows-latest"

steps:
- uses: "actions/checkout@v2"
Index: cachecontrol-0.12.12/cachecontrol/serialize.py
===================================================================
--- cachecontrol-0.12.12.orig/cachecontrol/serialize.py
+++ cachecontrol-0.12.12/cachecontrol/serialize.py
@@ -51,7 +51,6 @@ class Serializer(object):
u"status": response.status,
u"version": response.version,
u"reason": text_type(response.reason),
- u"strict": response.strict,
u"decode_content": response.decode_content,
}
}
@@ -138,6 +137,9 @@ class Serializer(object):
# TypeError: 'str' does not support the buffer interface
body = io.BytesIO(body_raw.encode("utf8"))

+ # Discard any `strict` parameter serialized by older version of cachecontrol.
+ cached["response"].pop("strict", None)
+
return HTTPResponse(body=body, preload_content=False, **cached["response"])

def _loads_v0(self, request, data, body_file=None):
Index: cachecontrol-0.12.12/tests/test_etag.py
===================================================================
--- cachecontrol-0.12.12.orig/tests/test_etag.py
+++ cachecontrol-0.12.12/tests/test_etag.py
@@ -1,6 +1,8 @@
# SPDX-FileCopyrightText: 2015 Eric Larson
#
# SPDX-License-Identifier: Apache-2.0
+from contextlib import ExitStack
+from contextlib import suppress

import pytest

@@ -134,11 +136,20 @@ class TestReleaseConnection(object):

resp = Mock(status=304, headers={})

- # This is how the urllib3 response is created in
- # requests.adapters
- response_mod = "requests.adapters.HTTPResponse.from_httplib"
+ # These are various ways the the urllib3 response can created
+ # in requests.adapters. Which one is actually used depends
+ # on which version if `requests` is in use, as well as perhaps
+ # other parameters.
+ response_mods = [
+ "requests.adapters.HTTPResponse.from_httplib",
+ "urllib3.HTTPConnectionPool.urlopen",
+ ]
+
+ with ExitStack() as stack:
+ for mod in response_mods:
+ with suppress(ImportError, AttributeError):
+ stack.enter_context(patch(mod, Mock(return_value=resp)))

- with patch(response_mod, Mock(return_value=resp)):
sess.get(etag_url)
assert resp.read.called
assert resp.release_conn.called
Index: cachecontrol-0.12.12/tests/test_vary.py
===================================================================
--- cachecontrol-0.12.12.orig/tests/test_vary.py
+++ cachecontrol-0.12.12/tests/test_vary.py
@@ -33,7 +33,6 @@ class TestVary(object):
cached.status == resp.raw.status,
cached.version == resp.raw.version,
cached.reason == resp.raw.reason,
- cached.strict == resp.raw.strict,
cached.decode_content == resp.raw.decode_content,
]

0 comments on commit 9402475

Please sign in to comment.