`test_warnings` not restoring filters for free threading tests
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 77.2k
- Forks
- 35.9k
- PR merge metrics
- PR metrics pending
Description
Bug description:
PYTHONWARNINGS=default ./python.exe -W default -m test test_warnings
Using random seed: 2934466897
0:00:00 load avg: 8.99 mem: 287.4 MiB Run 1 test sequentially in a single process
0:00:00 load avg: 8.99 mem: 287.4 MiB [1/1] test_warnings
Warning -- warnings.filters was modified by test_warnings
Warning -- Before: (12918522352, [('default', None, <class 'Warning'>, None, 0)], [('default', None, <class 'Warning'>, None, 0)])
Warning -- After: (12918522352, [('default', None, <class 'Warning'>, None, 0)], [])
0:00:20 load avg: 7.32 mem: 392.4 MiB [1/1/1] test_warnings failed (env changed)
This appears to race because the setUp is calling resetwarnings without getting it's own context.
This does not appear on the Cpython CI since --py-debug is used I believe which starts the warnings filter by default as an empty list so less likely to race, this occurred to me when running cpython tests against a release build and this test would not work.
The root cause I think is due to regr test asserting that the env hasn't been changed, however due to starting the test with warnings that are cleared this does not hold true
CPython versions tested on:
CPython main branch
Operating systems tested on:
Macos
Linked PRs
- gh-155609
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running PYTHONWARNINGS=default ./python.exe -W default -m test test_warnings and inspect the test_warnings setup around resetwarnings. Check how the regression test compares the warnings environment before and after; done means the test restores its filters and the command no longer reports an environment change.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- testing-qa
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100