mirror of
https://github.com/python/cpython.git
synced 2025-10-14 18:59:46 +00:00
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().
This commit is contained in:
parent
58498bc717
commit
fb4ae152a9
10 changed files with 185 additions and 51 deletions
|
@ -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):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue