This is an automated email from the ASF dual-hosted git repository.

raulcd pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow.git


The following commit(s) were added to refs/heads/main by this push:
     new 86b860fc4e GH-49044: [CI][Python] Fix test_download_tzdata_on_windows 
by adding required user-agent on urllib request (#49052)
86b860fc4e is described below

commit 86b860fc4e95947b640b6413321b9b1fecc133c1
Author: Rok Mihevc <[email protected]>
AuthorDate: Thu Jan 29 12:41:41 2026 +0100

    GH-49044: [CI][Python] Fix test_download_tzdata_on_windows by adding 
required user-agent on urllib request (#49052)
    
    ### Rationale for this change
    
    See: #49044
    
    ### What changes are included in this PR?
    
    Urllib now request with `"user-agent": "pyarrow"`
    
    ### Are these changes tested?
    
    It's a CI fix.
    
    ### Are there any user-facing changes?
    
    No, just a CI test fix.
    * GitHub Issue: #49044
    
    Authored-by: Rok Mihevc <[email protected]>
    Signed-off-by: Raúl Cumplido <[email protected]>
---
 python/pyarrow/util.py | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/python/pyarrow/util.py b/python/pyarrow/util.py
index 5878d1f902..a95826e1c0 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())
 
@@ -264,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  # noqa: F401
+        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)

Reply via email to