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 ncoghlan
Recipients eric.snow, htgoebel, ncoghlan, ned.deily, pmpp, springermac, vstinner
Date 2018-03-24.13:14:00
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1521897240.96.0.467229070634.issue33042@psf.upfronthosting.co.za>
In-reply-to
Content
PR has been updated to be mostly complete (just pending docs changes now), but I think I've found a potential issue with the interaction between the way I've currently implemented it and the way _Py_InitializeCore and _Py_InitializeMainInterpreter work.

Specifically, sys.warnoptions and sys._xoptions don't get created until _PySys_EndInit, so that's where I added the code to read the pre-initialization linked lists and move those values into sys.warnoptions and sys._xoptions. The current test is just checking that those sys attribute have the expected contents - it isn't checking that the consequences of those settings have correctly propagated to the warnings filter list.

For the default filters add by `_PyWarnings_Init` at the end of `_Py_InitializeCore`, I think that's fine - we're going to want the embedding application's filters to be add after the default filter list anyway.

However, the code in `_PyInitialize_MainInterpreter` to actually import the warnings module (which then reads `sys.warnoptions`) is guarded by a check for a non-empty config->warnoptions, and that's not going to trip in the case where get_warnoptions() has created a new sys.warnoptions list, and config->warnoptions is still NULL.

Rather than changing the preinit sys module code to be config-aware, I'm thinking that what I'd like to do is:

1. Update the new test case to also check that the most recent 3 entries in the warnings filter list match what we expect
2. Assuming that fails (as I expect it will), change the guard in _Py_InitializeMainInterpreter to check PySys_HasWarnOptions (which will correctly handle the case where config->warnoptions is NULL, but entries have been added to sys.warnoptions by some other mechanism, like PySys_AddWarnOption)
History
Date User Action Args
2018-03-24 13:14:01ncoghlansetrecipients: + ncoghlan, htgoebel, vstinner, ned.deily, pmpp, eric.snow, springermac
2018-03-24 13:14:00ncoghlansetmessageid: <1521897240.96.0.467229070634.issue33042@psf.upfronthosting.co.za>
2018-03-24 13:14:00ncoghlanlinkissue33042 messages
2018-03-24 13:14:00ncoghlancreate