diff options
author | Eric Snow <ericsnowcurrently@gmail.com> | 2022-12-07 22:56:31 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-12-07 22:56:31 (GMT) |
commit | 91a8e002c21a5388c5152c5a4871b9a2d85f0fc1 (patch) | |
tree | e6be380d88efc246ca7b4f864a67fc541a62b861 /Python/initconfig.c | |
parent | d47ffeb9e35dbc7264ffa12fddaa6e0d3ba767a4 (diff) | |
download | cpython-91a8e002c21a5388c5152c5a4871b9a2d85f0fc1.zip cpython-91a8e002c21a5388c5152c5a4871b9a2d85f0fc1.tar.gz cpython-91a8e002c21a5388c5152c5a4871b9a2d85f0fc1.tar.bz2 |
gh-81057: Move More Globals to _PyRuntimeState (gh-100092)
https://github.com/python/cpython/issues/81057
Diffstat (limited to 'Python/initconfig.c')
-rw-r--r-- | Python/initconfig.c | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/Python/initconfig.c b/Python/initconfig.c index 67f6777..64ae987 100644 --- a/Python/initconfig.c +++ b/Python/initconfig.c @@ -595,17 +595,13 @@ _Py_ClearStandardStreamEncoding(void) /* --- Py_GetArgcArgv() ------------------------------------------- */ -/* For Py_GetArgcArgv(); set by _Py_SetArgcArgv() */ -static PyWideStringList orig_argv = {.length = 0, .items = NULL}; - - void _Py_ClearArgcArgv(void) { PyMemAllocatorEx old_alloc; _PyMem_SetDefaultAllocator(PYMEM_DOMAIN_RAW, &old_alloc); - _PyWideStringList_Clear(&orig_argv); + _PyWideStringList_Clear(&_PyRuntime.orig_argv); PyMem_SetAllocator(PYMEM_DOMAIN_RAW, &old_alloc); } @@ -620,7 +616,9 @@ _Py_SetArgcArgv(Py_ssize_t argc, wchar_t * const *argv) PyMemAllocatorEx old_alloc; _PyMem_SetDefaultAllocator(PYMEM_DOMAIN_RAW, &old_alloc); - res = _PyWideStringList_Copy(&orig_argv, &argv_list); + // XXX _PyRuntime.orig_argv only gets cleared by Py_Main(), + // so it it currently leaks for embedders. + res = _PyWideStringList_Copy(&_PyRuntime.orig_argv, &argv_list); PyMem_SetAllocator(PYMEM_DOMAIN_RAW, &old_alloc); return res; @@ -631,8 +629,8 @@ _Py_SetArgcArgv(Py_ssize_t argc, wchar_t * const *argv) void Py_GetArgcArgv(int *argc, wchar_t ***argv) { - *argc = (int)orig_argv.length; - *argv = orig_argv.items; + *argc = (int)_PyRuntime.orig_argv.length; + *argv = _PyRuntime.orig_argv.items; } |