]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-134262: Fix off by one errors in download retry functions (GH-134867)
authorEmma Smith <emma@emmatyping.dev>
Wed, 28 May 2025 23:15:39 +0000 (16:15 -0700)
committerGitHub <noreply@github.com>
Wed, 28 May 2025 23:15:39 +0000 (18:15 -0500)
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 ecb7b54f6d8a13b12ed1443d990d623ea80ed312..df52f8de762a01d4136362d2b8232040c3cb6973 100644 (file)
@@ -169,7 +169,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: