From d6b41b637ea0b44639ca158da1e286c42269d184 Mon Sep 17 00:00:00 2001 From: Rok Mihevc Date: Thu, 29 Jan 2026 01:50:20 +0100 Subject: [PATCH 1/3] provide user-agent --- python/pyarrow/util.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/python/pyarrow/util.py b/python/pyarrow/util.py index 5878d1f90262..42bbf71496ce 100644 --- a/python/pyarrow/util.py +++ b/python/pyarrow/util.py @@ -231,8 +231,9 @@ def _break_traceback_cycle_from_frame(frame): def _download_urllib(url, out_path): - from urllib.request import urlopen - with urlopen(url) as response: + from urllib.request import urlopen, Request + req = Request(url, headers={'User-Agent': 'pyarrow'}) + with urlopen(req) as response: with open(out_path, 'wb') as f: f.write(response.read()) From f2250ca5ebdfa84f29c92fca5e71b5698cb128ab Mon Sep 17 00:00:00 2001 From: Rok Mihevc Date: Thu, 29 Jan 2026 10:55:01 +0100 Subject: [PATCH 2/3] review feedback --- python/pyarrow/util.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/python/pyarrow/util.py b/python/pyarrow/util.py index 42bbf71496ce..edb306ecb2f7 100644 --- a/python/pyarrow/util.py +++ b/python/pyarrow/util.py @@ -265,11 +265,13 @@ def download_tzdata_on_windows(): # Try to download the files with requests and then fall back to urllib. This # works around possible issues in certain older environment (GH-45295) try: - _download_requests(tzdata_url, tzdata_compressed_path) - _download_requests(windows_zones_url, windows_zones_path) + import requests + download_fn = _download_requests except ImportError: - _download_urllib(tzdata_url, tzdata_compressed_path) - _download_urllib(windows_zones_url, windows_zones_path) + download_fn = _download_urllib + + download_fn(tzdata_url, tzdata_compressed_path) + download_fn(windows_zones_url, windows_zones_path) assert os.path.exists(tzdata_compressed_path) assert os.path.exists(windows_zones_path) From 8fc6e17d952c224739d0ae57d9e7fa741c559cb4 Mon Sep 17 00:00:00 2001 From: Rok Mihevc Date: Thu, 29 Jan 2026 11:03:22 +0100 Subject: [PATCH 3/3] lint --- python/pyarrow/util.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/pyarrow/util.py b/python/pyarrow/util.py index edb306ecb2f7..a95826e1c005 100644 --- a/python/pyarrow/util.py +++ b/python/pyarrow/util.py @@ -265,7 +265,7 @@ def download_tzdata_on_windows(): # Try to download the files with requests and then fall back to urllib. This # works around possible issues in certain older environment (GH-45295) try: - import requests + import requests # noqa: F401 download_fn = _download_requests except ImportError: download_fn = _download_urllib