diff options
author | Victor Stinner <vstinner@redhat.com> | 2019-09-29 23:40:17 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-09-29 23:40:17 (GMT) |
commit | fb4ae152a9930f0e00cae8b2807f534058cf341a (patch) | |
tree | 557401018629793ae3de044ca7024384a0e4f3fa /Lib/test/test_embed.py | |
parent | 58498bc7178608b1ab031994ca09c43889ce3e76 (diff) | |
download | cpython-fb4ae152a9930f0e00cae8b2807f534058cf341a.zip cpython-fb4ae152a9930f0e00cae8b2807f534058cf341a.tar.gz cpython-fb4ae152a9930f0e00cae8b2807f534058cf341a.tar.bz2 |
bpo-38317: Fix PyConfig.warnoptions priority (GH-16478)
Fix warnings options priority: PyConfig.warnoptions has the highest
priority, as stated in the PEP 587.
* Document options order in PyConfig.warnoptions documentation.
* Make PyWideStringList_INIT macro private: replace "Py" prefix
with "_Py".
* test_embed: add test_init_warnoptions().
Diffstat (limited to 'Lib/test/test_embed.py')
-rw-r--r-- | Lib/test/test_embed.py | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/Lib/test/test_embed.py b/Lib/test/test_embed.py index ab086e2..b87863a 100644 --- a/Lib/test/test_embed.py +++ b/Lib/test/test_embed.py @@ -746,9 +746,9 @@ class InitConfigTests(EmbeddingTestsMixin, unittest.TestCase): 'cmdline_xoption', ], 'warnoptions': [ - 'config_warnoption', 'cmdline_warnoption', 'default::BytesWarning', + 'config_warnoption', ], 'run_command': 'pass\n', @@ -952,9 +952,9 @@ class InitConfigTests(EmbeddingTestsMixin, unittest.TestCase): 'faulthandler', ], 'warnoptions': [ - 'ignore:::config_warnoption', 'ignore:::cmdline_warnoption', 'ignore:::sysadd_warnoption', + 'ignore:::config_warnoption', ], } self.check_all_configs("test_init_sys_add", config, api=API_PYTHON) @@ -1268,6 +1268,30 @@ class InitConfigTests(EmbeddingTestsMixin, unittest.TestCase): self.assertEqual(Py_GetProgramFullPath(), config['executable']) self.assertEqual(Py_GetPythonHome(), config['home']) + def test_init_warnoptions(self): + # lowest to highest priority + warnoptions = [ + 'ignore:::PyConfig_Insert0', # PyWideStringList_Insert(0) + 'default', # PyConfig.dev_mode=1 + 'ignore:::env1', # PYTHONWARNINGS env var + 'ignore:::env2', # PYTHONWARNINGS env var + 'ignore:::cmdline1', # -W opt command line option + 'ignore:::cmdline2', # -W opt command line option + 'default::BytesWarning', # PyConfig.bytes_warnings=1 + 'ignore:::PySys_AddWarnOption1', # PySys_AddWarnOption() + 'ignore:::PySys_AddWarnOption2', # PySys_AddWarnOption() + 'ignore:::PyConfig_BeforeRead', # PyConfig.warnoptions + 'ignore:::PyConfig_AfterRead'] # PyWideStringList_Append() + preconfig = dict(allocator=PYMEM_ALLOCATOR_DEBUG) + config = { + 'dev_mode': 1, + 'faulthandler': 1, + 'bytes_warning': 1, + 'warnoptions': warnoptions, + } + self.check_all_configs("test_init_warnoptions", config, preconfig, + api=API_PYTHON) + class AuditingTests(EmbeddingTestsMixin, unittest.TestCase): def test_open_code_hook(self): |