This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vstinner
Recipients ncoghlan, vstinner
Date 2017-12-06.11:04:32
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
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)]

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.
Date User Action Args
2017-12-06 11:04:32vstinnersetrecipients: + vstinner, ncoghlan
2017-12-06 11:04:32vstinnersetmessageid: <>
2017-12-06 11:04:32vstinnerlinkissue32231 messages
2017-12-06 11:04:32vstinnercreate