diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2017-12-14 11:05:26 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-12-14 11:05:26 (GMT) |
commit | 374c6e178a7599aae46c857b17c6c8bc19dfe4c2 (patch) | |
tree | 54d60a3dce0e5b2285a887710f7e9204a5b1faec /Python/pylifecycle.c | |
parent | 53f7a7c2814fbfd8a29200926601a32fa48bacb3 (diff) | |
download | cpython-374c6e178a7599aae46c857b17c6c8bc19dfe4c2.zip cpython-374c6e178a7599aae46c857b17c6c8bc19dfe4c2.tar.gz cpython-374c6e178a7599aae46c857b17c6c8bc19dfe4c2.tar.bz2 |
bpo-32030: Add _PyMainInterpreterConfig.warnoptions (#4855)
Add warnoptions and xoptions fields to _PyMainInterpreterConfig.
Diffstat (limited to 'Python/pylifecycle.c')
-rw-r--r-- | Python/pylifecycle.c | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/Python/pylifecycle.c b/Python/pylifecycle.c index 31965f5..d813ddd 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(); } |