[issue28688] Warning -- warnings.filters was modified by test_warnings

STINNER Victor report at bugs.python.org
Thu Nov 17 10:30:53 EST 2016


STINNER Victor added the comment:

Hum, this issue is a regression caused by the issue #23839. The environment warning was already fixed by the issue #18383 (duplicate: issue #26742):

New changeset f57f4e33ba5e by Martin Panter in branch '3.5':
Issue #18383: Avoid adding duplicate filters when warnings is reloaded
https://hg.python.org/cpython/rev/f57f4e33ba5e

The problem is that _sre.SRE_Pattern doesn't import rich compare: so two patterns are only equal if it's exactly the same object... which is likely when re caches the compiled expression... But the Python test runner now starts by clearing the re cache!

I see different options:

* Find something else to not re-initialize warning filters, "_processoptions(sys.warnoptions)" in warnings.py.
* Fix warnings._add_filter() to implement a custom comparator operator for regular expression objects: compare pattern and flags
* Implement comparision in _sre.SRE_Pattern

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue28688>
_______________________________________


More information about the Python-bugs-list mailing list