Author ncoghlan
Recipients ncoghlan, vstinner
Date 2017-12-06.11:28:32
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1512559712.53.0.213398074469.issue32230@psf.upfronthosting.co.za>
In-reply-to
Content
Right, I hit some of those corner cases myself before I realised that pymain_add_warnings_options was the right place to inject "default" into sys.warnoptions after your refactoring improvements. It provides a nice pivot point where the command line machinery can decide relative priority and turn things into a neatly ordered list.

That gives the following priority order in my PR:

- first we add the filters from PYTHONWARNINGS
- then we optionally add an extra "default" entry based on core_config->dev_mode (which may be from either PYTHONDEVMODE or from "-X dev")
- then we add the filters from "-W" command line options

The "last added, first applied" behaviour of "warnings.simplefilter" then means that later entries in that list take precedence over earlier entries.

If we go on to also implement https://bugs.python.org/issue32231, then we'd add a 4th step to inject a "default::BytesWarning" or "error::BytesWarning" filter at the end based on cmdline->bytes_warning.
History
Date User Action Args
2017-12-06 11:28:32ncoghlansetrecipients: + ncoghlan, vstinner
2017-12-06 11:28:32ncoghlansetmessageid: <1512559712.53.0.213398074469.issue32230@psf.upfronthosting.co.za>
2017-12-06 11:28:32ncoghlanlinkissue32230 messages
2017-12-06 11:28:32ncoghlancreate