summaryrefslogtreecommitdiffstats
path: root/Python/initconfig.c
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@redhat.com>2019-08-23 19:16:51 (GMT)
committerGitHub <noreply@github.com>2019-08-23 19:16:51 (GMT)
commitaf84a88ef8b3288da528d2f52b7d3fbafb8dc8a6 (patch)
treeb9f0a48a09eb7783ee3b35e9f2381ea2f791b9d9 /Python/initconfig.c
parent3921d12174c1998d9df7a08d036a7fef2d587a64 (diff)
downloadcpython-af84a88ef8b3288da528d2f52b7d3fbafb8dc8a6.zip
cpython-af84a88ef8b3288da528d2f52b7d3fbafb8dc8a6.tar.gz
cpython-af84a88ef8b3288da528d2f52b7d3fbafb8dc8a6.tar.bz2
bpo-36763: PyConfig_Read() handles PySys_AddXOption() (GH-15431) (GH-15435)
PyConfig_Read() is now responsible to handle early calls to PySys_AddXOption() and PySys_AddWarnOption(). Options added by PySys_AddXOption() are now handled the same way than PyConfig.xoptions and command line -X options. For example, PySys_AddXOption(L"faulthandler") enables faulthandler as expected. (cherry picked from commit 120b707a6d43452e067daa55a8fdca69f9424abc)
Diffstat (limited to 'Python/initconfig.c')
-rw-r--r--Python/initconfig.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/Python/initconfig.c b/Python/initconfig.c
index 8a6ad7c..a87d8ae 100644
--- a/Python/initconfig.c
+++ b/Python/initconfig.c
@@ -2069,6 +2069,7 @@ config_init_warnoptions(PyConfig *config,
/* The priority order for warnings configuration is (highest precedence
* first):
*
+ * - early PySys_AddWarnOption() calls
* - the BytesWarning filter, if needed ('-b', '-bb')
* - any '-W' command line options; then
* - the 'PYTHONWARNINGS' environment variable; then
@@ -2124,6 +2125,13 @@ config_init_warnoptions(PyConfig *config,
return status;
}
}
+
+ /* Handle early PySys_AddWarnOption() calls */
+ status = _PySys_ReadPreinitWarnOptions(config);
+ if (_PyStatus_EXCEPTION(status)) {
+ return status;
+ }
+
return _PyStatus_OK();
}
@@ -2246,7 +2254,8 @@ config_read_cmdline(PyConfig *config)
}
status = config_init_warnoptions(config,
- &cmdline_warnoptions, &env_warnoptions);
+ &cmdline_warnoptions,
+ &env_warnoptions);
if (_PyStatus_EXCEPTION(status)) {
goto done;
}
@@ -2356,6 +2365,12 @@ PyConfig_Read(PyConfig *config)
goto done;
}
+ /* Handle early PySys_AddXOption() calls */
+ status = _PySys_ReadPreinitXOptions(config);
+ if (_PyStatus_EXCEPTION(status)) {
+ goto done;
+ }
+
status = config_read(config);
if (_PyStatus_EXCEPTION(status)) {
goto done;