Skip to content

Commit d5db3f4

Browse files
committed
Always close download connection
1 parent c7a85b8 commit d5db3f4

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

hypothesis-python/RELEASE.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
RELEASE_TYPE: patch
2+
3+
This patch ensures that we always close the download connection in
4+
:class:`~hypothesis.database.GitHubArtifactDatabase`.

hypothesis-python/src/hypothesis/database.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -561,11 +561,11 @@ def _get_bytes(self, url: str) -> Optional[bytes]: # pragma: no cover
561561
"Authorization": f"Bearer {self.token}",
562562
},
563563
)
564+
warning_message = None
564565
response_bytes: Optional[bytes] = None
565566
try:
566-
response = urlopen(request)
567-
response_bytes = response.read()
568-
warning_message = None
567+
with urlopen(request) as response:
568+
response_bytes = response.read()
569569
except HTTPError as e:
570570
if e.code == 401:
571571
warning_message = (

0 commit comments

Comments
 (0)