Author vstinner
Recipients ncoghlan, vstinner
Date 2017-12-06.11:04:32
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1512558272.88.0.213398074469.issue32231@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2017-12-06 11:04:32vstinnersetrecipients: + vstinner, ncoghlan
2017-12-06 11:04:32vstinnersetmessageid: <1512558272.88.0.213398074469.issue32231@psf.upfronthosting.co.za>
2017-12-06 11:04:32vstinnerlinkissue32231 messages
2017-12-06 11:04:32vstinnercreate