Skip to content

Commit e9acedc

Browse files
jsignellkmodali
authored andcommitted
Support older versions of urllib3 (#1580)
1 parent 7537078 commit e9acedc

File tree

4 files changed

+8
-7
lines changed

4 files changed

+8
-7
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ dev = [
5454
"types-orjson>=3.6.2",
5555
"types-python-dateutil>=2.9.0.20241003",
5656
"types-urllib3>=1.26.25.14",
57-
"urllib3>=2.3.0",
57+
"urllib3>=1.26.19",
5858
"virtualenv>=20.26.6",
5959
]
6060
docs = [

pystac/stac_io.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -286,9 +286,9 @@ def read_text_from_href(self, href: str) -> str:
286286
"""Reads file as a UTF-8 string.
287287
288288
If ``href`` has a "scheme" (e.g. if it starts with "https://") then this will
289-
use :func:`urllib.request.urlopen` (or func:`urllib3.request` if available)
290-
to open the file and read the contents; otherwise, :func:`open` will be used
291-
to open a local file.
289+
use :func:`urllib.request.urlopen` (or func:`urllib3.PoolManager().request`
290+
if available) to open the file and read the contents; otherwise, :func:`open`
291+
will be used to open a local file.
292292
293293
Args:
294294
@@ -299,7 +299,8 @@ def read_text_from_href(self, href: str) -> str:
299299
try:
300300
logger.debug(f"GET {href} Headers: {self.headers}")
301301
if HAS_URLLIB3:
302-
with urllib3.request(
302+
http = urllib3.PoolManager()
303+
with http.request(
303304
"GET",
304305
href,
305306
headers={

tests/test_stac_io.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ class ReportingStacIO(DefaultStacIO, DuplicateKeyReportingMixin):
117117
assert str(excinfo.value), f'Found duplicate object name "key" in {src_href}'
118118

119119

120-
@unittest.mock.patch("pystac.stac_io.urllib3.request")
120+
@unittest.mock.patch("pystac.stac_io.urllib3.PoolManager.request")
121121
def test_headers_stac_io(request_mock: unittest.mock.MagicMock) -> None:
122122
stac_io = DefaultStacIO(headers={"Authorization": "api-key fake-api-key-value"})
123123

uv.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)