From 374c6e178a7599aae46c857b17c6c8bc19dfe4c2 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Thu, 14 Dec 2017 12:05:26 +0100 Subject: bpo-32030: Add _PyMainInterpreterConfig.warnoptions (#4855) Add warnoptions and xoptions fields to _PyMainInterpreterConfig. --- Python/pylifecycle.c | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) (limited to 'Python/pylifecycle.c') diff --git a/Python/pylifecycle.c b/Python/pylifecycle.c index 31965f503c..d813ddd671 100644 --- a/Python/pylifecycle.c +++ b/Python/pylifecycle.c @@ -830,6 +830,8 @@ _PyMainInterpreterConfig_Clear(_PyMainInterpreterConfig *config) { Py_CLEAR(config->argv); Py_CLEAR(config->module_search_path); + Py_CLEAR(config->warnoptions); + Py_CLEAR(config->xoptions); } @@ -883,10 +885,26 @@ _Py_InitializeMainInterpreter(const _PyMainInterpreterConfig *config) return _Py_INIT_ERR("can't initialize time"); } + /* Set sys attributes */ assert(interp->config.module_search_path != NULL); if (PySys_SetObject("path", interp->config.module_search_path) != 0) { return _Py_INIT_ERR("can't assign sys.path"); } + if (interp->config.argv != NULL) { + if (PySys_SetObject("argv", interp->config.argv) != 0) { + return _Py_INIT_ERR("can't assign sys.argv"); + } + } + if (interp->config.warnoptions != NULL) { + if (PySys_SetObject("warnoptions", interp->config.warnoptions)) { + return _Py_INIT_ERR("can't assign sys.warnoptions"); + } + } + if (interp->config.xoptions != NULL) { + if (PySys_SetObject("_xoptions", interp->config.xoptions)) { + return _Py_INIT_ERR("can't assign sys._xoptions"); + } + } if (_PySys_EndInit(interp->sysdict) < 0) return _Py_INIT_ERR("can't finish initializing sys"); @@ -945,13 +963,6 @@ _Py_InitializeMainInterpreter(const _PyMainInterpreterConfig *config) return err; } } - - if (interp->config.argv != NULL) { - if (PySys_SetObject("argv", interp->config.argv) != 0) { - return _Py_INIT_ERR("can't assign sys.argv"); - } - } - return _Py_INIT_OK(); } -- cgit v1.2.1