New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[EASY] test_warnings: test_exec_filename() fails when run with -Werror #78093
Comments
vstinner@apu$ ./python -W error -m test -v test_warnings ====================================================================== Traceback (most recent call last):
File "/home/vstinner/prog/python/master/Lib/test/test_warnings/__init__.py", line 450, in test_exec_filename
exec(codeobj)
File "<warnings-test>", line 2, in <module>
UserWarning: hello ====================================================================== Traceback (most recent call last):
File "/home/vstinner/prog/python/master/Lib/test/test_warnings/__init__.py", line 450, in test_exec_filename
exec(codeobj)
File "<warnings-test>", line 2, in <module>
File "/home/vstinner/prog/python/master/Lib/warnings.py", line 318, in warn
globals, source)
File "/home/vstinner/prog/python/master/Lib/warnings.py", line 363, in warn_explicit
raise message
UserWarning: hello It seems to be a regression introduced by bpo-33375: commit 11a8966. |
I consider that this issue is easy, core developers/long time contriubtors: please don't fix it, but explain how to fix it and let a newcomer to fix it! |
Yes, this should be easy. I misunderstood how to use the catch_warnings context manager. I thought that catch_warnings itself set up the warnings filters you need. You actually need to do that with a separate call inside the with block, as shown here: https://docs.python.org/3/library/warnings.html#testing-warnings |
Thank you Christopher Frederickson for your contribution! I merged your PR. I confirm that it fixes the issue. Thanks Thomas Kluyver for the hints ;-) |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: