Message306328
| Author |
vstinner |
| Recipients |
barry, eric.snow, ncoghlan, vstinner |
| Date |
2017年11月16日.02:04:31 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<1510797872.08.0.213398074469.issue32030@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
Nick:
"""
I noticed the other day that the interaction between PYTHONWARNINGS, the `-W` option, sys.warnoptions, and _warnings.filters is a bit confusing:
$ PYTHONWARNINGS=always,default python3 -Wignore -Wonce
(...)
>>> sys.warnoptions
['always', 'default', 'ignore', 'once']
>>> [f[0] for f in _warnings.filters[:4]]
['once', 'ignore', 'default', 'always']
"""
IMHO the command line must have the priority over environment variables, since environment variables are inherited, whereas the command line can be finely tuned *on purpose*. So it's correct, no? It's just that warnoptions gives options in the reverse order than the "expected" order, no?
At least, with my commit, if you want to try to change the priority, you just have to exchange two lines in pymain_add_warnings_options() :-)
if (pymain_add_warnings_optlist(&pymain->env_warning_options) < 0) ...
if (pymain_add_warnings_optlist(&pymain->cmdline.warning_options) < 0) ...
--
By the way, I'm not sure that it was a good idea to expose sys.warnoptions to users, but I don't think that we can remove it anymore :-) |
|
History
|
|---|
| Date |
User |
Action |
Args |
| 2017年11月16日 02:04:32 | vstinner | set | recipients:
+ vstinner, barry, ncoghlan, eric.snow |
| 2017年11月16日 02:04:32 | vstinner | set | messageid: <1510797872.08.0.213398074469.issue32030@psf.upfronthosting.co.za> |
| 2017年11月16日 02:04:32 | vstinner | link | issue32030 messages |
| 2017年11月16日 02:04:31 | vstinner | create |
|