Skip to content

Commit

Permalink
Move static_arg_parsers into _PyRuntimeState.
Browse files Browse the repository at this point in the history
  • Loading branch information
ericsnowcurrently committed Nov 14, 2022
1 parent 5c4fde4 commit 3d803e9
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 11 deletions.
1 change: 1 addition & 0 deletions Include/internal/pycore_interp.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ extern "C" {
#include "pycore_unicodeobject.h" // struct _Py_unicode_state
#include "pycore_warnings.h" // struct _warnings_runtime_state


struct _pending_calls {
PyThread_type_lock lock;
/* Request for running pending calls. */
Expand Down
3 changes: 2 additions & 1 deletion Include/internal/pycore_runtime.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ extern "C" {
#include "pycore_unicodeobject.h" // struct _Py_unicode_runtime_ids

struct _getargs_runtime_state {
PyThread_type_lock mutex;
PyThread_type_lock mutex;
struct _PyArg_Parser *static_parsers;
};

/* ceval state */
Expand Down
11 changes: 4 additions & 7 deletions Python/getargs.c
Original file line number Diff line number Diff line change
Expand Up @@ -1846,9 +1846,6 @@ vgetargskeywords(PyObject *args, PyObject *kwargs, const char *format,
}


/* List of static parsers. */
static struct _PyArg_Parser *static_arg_parsers = NULL;

static int
scan_keywords(const char * const *keywords, int *ptotal, int *pposonly)
{
Expand Down Expand Up @@ -2024,8 +2021,8 @@ _parser_init(struct _PyArg_Parser *parser)
parser->initialized = owned ? 1 : -1;

assert(parser->next == NULL);
parser->next = static_arg_parsers;
static_arg_parsers = parser;
parser->next = _PyRuntime.getargs.static_parsers;
_PyRuntime.getargs.static_parsers = parser;
return 1;
}

Expand Down Expand Up @@ -2930,14 +2927,14 @@ _PyArg_NoKwnames(const char *funcname, PyObject *kwnames)
void
_PyArg_Fini(void)
{
struct _PyArg_Parser *tmp, *s = static_arg_parsers;
struct _PyArg_Parser *tmp, *s = _PyRuntime.getargs.static_parsers;
while (s) {
tmp = s->next;
s->next = NULL;
parser_clear(s);
s = tmp;
}
static_arg_parsers = NULL;
_PyRuntime.getargs.static_parsers = NULL;
}

#ifdef __cplusplus
Expand Down
3 changes: 0 additions & 3 deletions Tools/c-analyzer/cpython/globals-to-fix.tsv
Original file line number Diff line number Diff line change
Expand Up @@ -327,9 +327,6 @@ Objects/unicodeobject.c - ucnhash_capi -
# local buffer
Python/suggestions.c levenshtein_distance buffer -

# linked list
Python/getargs.c - static_arg_parsers -

# other
Objects/dictobject.c - _pydict_global_version -
Objects/dictobject.c - next_dict_keys_version -
Expand Down

0 comments on commit 3d803e9

Please sign in to comment.