https://github.com/python/cpython/commit/785b39671982d270521010239f5d52d2d816a7b9 commit: 785b39671982d270521010239f5d52d2d816a7b9 branch: 3.13 author: Miss Islington (bot) <[email protected]> committer: emmatyping <[email protected]> date: 2025-08-14T12:56:42-07:00 summary:
[3.13] gh-134262: Catch both URLError and ConnectionError in retries (GH-135365) (#137779) gh-134262: Catch both URLError and ConnectionError in retries (GH-135365) (cherry picked from commit acc20a83f4d93682e91c4992c785eaf7e3d0c69c) Co-authored-by: Emma Smith <[email protected]> files: M PCbuild/get_external.py M Tools/build/generate_sbom.py diff --git a/PCbuild/get_external.py b/PCbuild/get_external.py index 8c1155c74a642c..a78aa6a23041ad 100755 --- a/PCbuild/get_external.py +++ b/PCbuild/get_external.py @@ -5,8 +5,9 @@ import pathlib import sys import time +import urllib.error +import urllib.request import zipfile -from urllib.request import urlretrieve def retrieve_with_retries(download_location, output_path, reporthook, @@ -14,12 +15,12 @@ def retrieve_with_retries(download_location, output_path, reporthook, """Download a file with exponential backoff retry and save to disk.""" for attempt in range(max_retries + 1): try: - resp = urlretrieve( + resp = urllib.request.urlretrieve( download_location, output_path, reporthook=reporthook, ) - except ConnectionError as ex: + except (urllib.error.URLError, ConnectionError) as ex: if attempt == max_retries: msg = f"Download from {download_location} failed." raise OSError(msg) from ex diff --git a/Tools/build/generate_sbom.py b/Tools/build/generate_sbom.py index 60fb21aa2cb730..23edd510946b4d 100644 --- a/Tools/build/generate_sbom.py +++ b/Tools/build/generate_sbom.py @@ -175,7 +175,7 @@ def download_with_retries(download_location: str, for attempt in range(max_retries + 1): try: resp = urllib.request.urlopen(download_location) - except urllib.error.URLError as ex: + except (urllib.error.URLError, ConnectionError) as ex: if attempt == max_retries: msg = f"Download from {download_location} failed." raise OSError(msg) from ex _______________________________________________ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3//lists/python-checkins.python.org Member address: [email protected]
