mirror of
https://github.com/python/cpython.git
synced 2025-08-31 14:07:50 +00:00
gh-81057: Move More Globals to _PyRuntimeState (gh-100092)
https://github.com/python/cpython/issues/81057
This commit is contained in:
parent
d47ffeb9e3
commit
91a8e002c2
14 changed files with 66 additions and 56 deletions
|
@ -673,10 +673,6 @@ mult(Bigint *a, Bigint *b)
|
|||
|
||||
#ifndef Py_USING_MEMORY_DEBUGGER
|
||||
|
||||
/* p5s is a linked list of powers of 5 of the form 5**(2**i), i >= 2 */
|
||||
|
||||
static Bigint *p5s;
|
||||
|
||||
/* multiply the Bigint b by 5**k. Returns a pointer to the result, or NULL on
|
||||
failure; if the returned pointer is distinct from b then the original
|
||||
Bigint b will have been Bfree'd. Ignores the sign of b. */
|
||||
|
@ -696,7 +692,7 @@ pow5mult(Bigint *b, int k)
|
|||
|
||||
if (!(k >>= 2))
|
||||
return b;
|
||||
p5 = p5s;
|
||||
p5 = _PyRuntime.dtoa.p5s;
|
||||
if (!p5) {
|
||||
/* first time */
|
||||
p5 = i2b(625);
|
||||
|
@ -704,7 +700,7 @@ pow5mult(Bigint *b, int k)
|
|||
Bfree(b);
|
||||
return NULL;
|
||||
}
|
||||
p5s = p5;
|
||||
_PyRuntime.dtoa.p5s = p5;
|
||||
p5->next = 0;
|
||||
}
|
||||
for(;;) {
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue