New submission from Oren Milman: The following code causes an assertion failure in warn_explicit() (in Python/_warnings.c):
import warnings warnings.filters = [(None, None, Warning, None, 0)] warnings.warn_explicit(message='foo', category=Warning, filename='bar', lineno=1) this is because warn_explicit() assumes that get_filter() returned a string, and passes the return value (of get_filter()) to _PyUnicode_EqualToASCIIString(), which asserts it received a string. In addition, get_filter() might return warnings.defaultaction, and so the following code also causes an assertion failure in warn_explicit(): import warnings warnings.defaultaction = None warnings.filters = [] warnings.warn_explicit(message='foo', category=Warning, filename='bar', lineno=1) ---------- components: Extension Modules messages: 301867 nosy: Oren Milman priority: normal severity: normal status: open title: assertion failures in warn_explicit() in case of a bad warnings.filters or warnings.defaultaction type: crash versions: Python 3.7 _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue31416> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com