Skip to content

Commit 3afc3c0

Browse files
authored
STY: Tiny readability improvement (py-pdf#2989)
1 parent 977b7ef commit 3afc3c0

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

tests/__init__.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,17 @@ def get_data_from_url(url: Optional[str] = None, name: Optional[str] = None) ->
4040
return fp.read()
4141
if not cache_path.exists():
4242
ssl._create_default_https_context = ssl._create_unverified_context
43-
cpt = 3
44-
while cpt > 0:
43+
attempts = 0
44+
while attempts < 3:
4545
try:
4646
with urllib.request.urlopen( # noqa: S310
4747
url
4848
) as response, cache_path.open("wb") as out_file:
4949
out_file.write(response.read())
50-
cpt = 0
50+
break
5151
except HTTPError as e:
52-
if cpt > 0:
53-
cpt -= 1
52+
if attempts < 3:
53+
attempts += 1
5454
else:
5555
raise e
5656
with open(cache_path, "rb") as fp:

0 commit comments

Comments
 (0)