[issue29672] `catch_warnings` context manager causes all warnings to be printed every time, even after exiting
Tom Aldcroft
report at bugs.python.org
Fri Apr 2 17:55:37 EDT 2021
Tom Aldcroft <taldcroft at gmail.com> added the comment:
I encountered this issue today and want to +1 getting some attention on this.
The disconnected nature of this issue makes it especially difficult to understand -- any package in the stack can change this hidden global variable `_filters_version` in the warnings module that then impacts the local behavior of warnings in the user script.
The only way I was able to finally understand that an update to an obscure dependency was breaking our regression testing was by reading the `warnings` source code and then monkey patching it to print diagnostic information.
Even a documentation update would be useful. This could explain not only `catch_warnings()`, but in general the unexpected feature that if any package anywhere in the stack sets a warning filter, then that globally resets whether a warning has been seen before (via the call to `_filters_mutated()`).
----------
nosy: +taldcroft
versions: -Python 3.5, Python 3.6, Python 3.7
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue29672>
_______________________________________
More information about the Python-bugs-list
mailing list