Skip to content

Commit

Permalink
Always close download connection
Browse files Browse the repository at this point in the history
  • Loading branch information
Zac-HD committed Aug 12, 2023
1 parent c7a85b8 commit d5db3f4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 4 additions & 0 deletions hypothesis-python/RELEASE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
RELEASE_TYPE: patch

This patch ensures that we always close the download connection in
:class:`~hypothesis.database.GitHubArtifactDatabase`.
6 changes: 3 additions & 3 deletions hypothesis-python/src/hypothesis/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -561,11 +561,11 @@ def _get_bytes(self, url: str) -> Optional[bytes]: # pragma: no cover
"Authorization": f"Bearer {self.token}",
},
)
warning_message = None
response_bytes: Optional[bytes] = None
try:
response = urlopen(request)
response_bytes = response.read()
warning_message = None
with urlopen(request) as response:
response_bytes = response.read()
except HTTPError as e:
if e.code == 401:
warning_message = (
Expand Down

0 comments on commit d5db3f4

Please sign in to comment.