From: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> Date: Thu, 14 Aug 2025 19:01:13 +0000 (+0200) Subject: [3.13] gh-134262: Fix off by one errors in download retry functions (GH-137775) X-Git-Tag: v3.13.8~190 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4c29fc2b021e2525bcd6e2556b8278de8bace812;p=thirdparty%2FPython%2Fcpython.git [3.13] gh-134262: Fix off by one errors in download retry functions (GH-137775) (cherry picked from commit e64395e8eb8d3a9e35e3e534e87d427ff27ab0a5) Co-authored-by: Emma Smith --- diff --git a/PCbuild/get_external.py b/PCbuild/get_external.py index 99aff63882f5..8c1155c74a64 100755 --- a/PCbuild/get_external.py +++ b/PCbuild/get_external.py @@ -12,7 +12,7 @@ from urllib.request import urlretrieve def retrieve_with_retries(download_location, output_path, reporthook, max_retries=7): """Download a file with exponential backoff retry and save to disk.""" - for attempt in range(max_retries): + for attempt in range(max_retries + 1): try: resp = urlretrieve( download_location, diff --git a/Tools/build/generate_sbom.py b/Tools/build/generate_sbom.py index 82f06f0a7e57..60fb21aa2cb7 100644 --- a/Tools/build/generate_sbom.py +++ b/Tools/build/generate_sbom.py @@ -172,7 +172,7 @@ def download_with_retries(download_location: str, base_delay: float = 2.25, max_jitter: float = 1.0) -> typing.Any: """Download a file with exponential backoff retry.""" - for attempt in range(max_retries): + for attempt in range(max_retries + 1): try: resp = urllib.request.urlopen(download_location) except urllib.error.URLError as ex: