New GitHub issue #107861 from sobolevn:<br>
<hr>
<pre>
## Modified env
Repro:
1. Install `hypothesis` into `venv` (`./python.exe -m venv .venv`, `source .venv/bin/activate`, `pip install hypothesis`)
2. Run `python -m test test_zoneinfo`
Result:
```
» python -m test test_zoneinfo
0:00:00 load avg: 1.06 Run tests sequentially
0:00:00 load avg: 1.06 [1/1] test_zoneinfo
/Users/sobolev/Desktop/cpython/.venv/lib/python3.13/site-packages/hypothesis/database.py:590: HypothesisWarning: Authorization failed when trying to download artifact from GitHub. Check that you have a valid GITHUB_TOKEN set in your environment.
warnings.warn(HypothesisWarning(warning_message))
/Users/sobolev/Desktop/cpython/.venv/lib/python3.13/site-packages/hypothesis/database.py:544: HypothesisWarning: Couldn't acquire a new or existing artifact. Disabling database.
warnings.warn(
Warning -- urllib.requests._opener was modified by test_zoneinfo
Warning -- Before: None
Warning -- After: <urllib.request.OpenerDirector object at 0x104d4eea0>
test_zoneinfo failed (env changed)
== Tests result: SUCCESS ==
1 test altered the execution environment:
test_zoneinfo
Total duration: 2.4 sec
Tests result: SUCCESS
```
This happens because `urlopen` is called here: https://github.com/HypothesisWorks/hypothesis/blob/c7a85b899a9eb8687402b3626742a7c8f73a69c2/hypothesis-python/src/hypothesis/database.py#L566 in `GitHubArtifactDatabase`, but it is never cleaned.
## Crash
Now, the same steps, but with `-R 3:3`:
```
» python -m test -R 3:3 test_zoneinfo
0:00:00 load avg: 1.42 Run tests sequentially
0:00:00 load avg: 1.42 [1/1] test_zoneinfo
beginning 6 repetitions
123456
/Users/sobolev/Desktop/cpython/.venv/lib/python3.13/site-packages/hypothesis/database.py:590: HypothesisWarning: Authorization failed when trying to download artifact from GitHub. Check that you have a valid GITHUB_TOKEN set in your environment.
warnings.warn(HypothesisWarning(warning_message))
/Users/sobolev/Desktop/cpython/.venv/lib/python3.13/site-packages/hypothesis/database.py:544: HypothesisWarning: Couldn't acquire a new or existing artifact. Disabling database.
warnings.warn(
[1] 93794 killed python -m test -R 3:3 test_zoneinfo
```
This only happens with `hypothesis` installed and when at least one `hypothesis` test is defined.
Example with no-hypothesis tests:
```
» python -m test -R 3:3 test_types test_typing
0:00:00 load avg: 1.20 Run tests sequentially
0:00:00 load avg: 1.20 [1/2] test_types
beginning 6 repetitions
123456
......
0:00:00 load avg: 1.18 [2/2] test_typing
beginning 6 repetitions
123456
......
== Tests result: SUCCESS ==
All 2 tests OK.
Total duration: 1.5 sec
Tests result: SUCCESS
```
</pre>
<hr>
<a href="https://github.com/python/cpython/issues/107861">View on GitHub</a>
<p>Labels: type-bug, tests, type-crash</p>
<p>Assignee: </p>