Nick Coghlan <ncogh...@gmail.com> added the comment:

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.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue32230>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to