]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.13] gh-134262: Fix off by one errors in download retry functions (GH-137775)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Thu, 14 Aug 2025 19:01:13 +0000 (21:01 +0200)
committerGitHub <noreply@github.com>
Thu, 14 Aug 2025 19:01:13 +0000 (19:01 +0000)
(cherry picked from commit e64395e8eb8d3a9e35e3e534e87d427ff27ab0a5)

Co-authored-by: Emma Smith <emma@emmatyping.dev>
PCbuild/get_external.py
Tools/build/generate_sbom.py

index 99aff63882f5baabf4ddca566b3fd4ee0f70961b..8c1155c74a642c5ef6748207a3bd6ac0cfa4f56b 100755 (executable)
@@ -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,
index 82f06f0a7e57f9d6c65320563a8c3070c5910a98..60fb21aa2cb73093c6713a8768dde245fc33bf3c 100644 (file)
@@ -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: