Skip to content

Commit 144753e

Browse files
Move static_arg_parsers into _PyRuntimeState.
1 parent 998fb5e commit 144753e

File tree

4 files changed

+7
-11
lines changed

4 files changed

+7
-11
lines changed

Include/internal/pycore_interp.h

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ extern "C" {
2626
#include "pycore_unicodeobject.h" // struct _Py_unicode_state
2727
#include "pycore_warnings.h" // struct _warnings_runtime_state
2828

29+
2930
struct _pending_calls {
3031
PyThread_type_lock lock;
3132
/* Request for running pending calls. */

Include/internal/pycore_runtime.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ extern "C" {
1919
#include "pycore_unicodeobject.h" // struct _Py_unicode_runtime_ids
2020

2121
struct _getargs_runtime_state {
22-
PyThread_type_lock mutex;
22+
PyThread_type_lock mutex;
23+
struct _PyArg_Parser *static_parsers;
2324
};
2425

2526
/* ceval state */

Python/getargs.c

+4-7
Original file line numberDiff line numberDiff line change
@@ -1846,9 +1846,6 @@ vgetargskeywords(PyObject *args, PyObject *kwargs, const char *format,
18461846
}
18471847

18481848

1849-
/* List of static parsers. */
1850-
static struct _PyArg_Parser *static_arg_parsers = NULL;
1851-
18521849
static int
18531850
scan_keywords(const char * const *keywords, int *ptotal, int *pposonly)
18541851
{
@@ -2024,8 +2021,8 @@ _parser_init(struct _PyArg_Parser *parser)
20242021
parser->initialized = owned ? 1 : -1;
20252022

20262023
assert(parser->next == NULL);
2027-
parser->next = static_arg_parsers;
2028-
static_arg_parsers = parser;
2024+
parser->next = _PyRuntime.getargs.static_parsers;
2025+
_PyRuntime.getargs.static_parsers = parser;
20292026
return 1;
20302027
}
20312028

@@ -2930,14 +2927,14 @@ _PyArg_NoKwnames(const char *funcname, PyObject *kwnames)
29302927
void
29312928
_PyArg_Fini(void)
29322929
{
2933-
struct _PyArg_Parser *tmp, *s = static_arg_parsers;
2930+
struct _PyArg_Parser *tmp, *s = _PyRuntime.getargs.static_parsers;
29342931
while (s) {
29352932
tmp = s->next;
29362933
s->next = NULL;
29372934
parser_clear(s);
29382935
s = tmp;
29392936
}
2940-
static_arg_parsers = NULL;
2937+
_PyRuntime.getargs.static_parsers = NULL;
29412938
}
29422939

29432940
#ifdef __cplusplus

Tools/c-analyzer/cpython/globals-to-fix.tsv

-3
Original file line numberDiff line numberDiff line change
@@ -328,9 +328,6 @@ Python/import.c - import_lock -
328328
# local buffer
329329
Python/suggestions.c levenshtein_distance buffer -
330330

331-
# linked list
332-
Python/getargs.c - static_arg_parsers -
333-
334331
# other
335332
Objects/dictobject.c - _pydict_global_version -
336333
Objects/dictobject.c - next_dict_keys_version -

0 commit comments

Comments
 (0)