https://github.com/python/cpython/commit/e64395e8eb8d3a9e35e3e534e87d427ff27ab0a5
commit: e64395e8eb8d3a9e35e3e534e87d427ff27ab0a5
branch: main
author: Emma Smith <e...@emmatyping.dev>
committer: zware <zachary.w...@gmail.com>
date: 2025-05-28T18:15:39-05:00
summary:

gh-134262: Fix off by one errors in download retry functions (GH-134867)

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 99aff63882f5ba..8c1155c74a642c 100755
--- a/PCbuild/get_external.py
+++ b/PCbuild/get_external.py
@@ -12,7 +12,7 @@
 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 ecb7b54f6d8a13..df52f8de762a01 100644
--- a/Tools/build/generate_sbom.py
+++ b/Tools/build/generate_sbom.py
@@ -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:

_______________________________________________
Python-checkins mailing list -- python-checkins@python.org
To unsubscribe send an email to python-checkins-le...@python.org
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: arch...@mail-archive.com

Reply via email to