STINNER Victor <victor.stin...@gmail.com> added the comment: IMHO the root issue is that there are different options which set warnings filters:
- PYTHONWARNINGS/-W will fill sys.warnoptions - sys.flags.bytes_warning (-b, -bb) and sys.flags.dev_mode (-X dev, PYTHONDEVMODE=1) which change the default filters vstinner@apu$ ./python -W default -b -c 'import pprint, sys, warnings; pprint.pprint(warnings.filters); pprint.pprint(sys.warnoptions)' [('default', None, <class 'Warning'>, None, 0), ('default', None, <class 'BytesWarning'>, None, 0), ('default', None, <class 'ResourceWarning'>, None, 0)] ['default'] Why default::BytesWarning isn't in sys.warnoptions? I suggest to experiment to create all filters at once in a single list, rather than having sys.warnoptions on one side and init_filters() (Python/_warnings.c) on another side. It was on my TODO list for the PEP 432 :-) Currently, when Python is embedded, it's not easy to control filters created by init_filters() which can be an issue. I expect a feature like Py_SetPath() to override *all* warnings filters, not only "add" filters on top on existing filters, for the specific case of embedded Python. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue32231> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com