diff options
author | Hai Shi <shihai1992@gmail.com> | 2020-01-30 17:20:25 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-01-30 15:20:25 -0800 |
commit | 46874c26ee1fc752e2e6930efa1d223b2351edb8 (patch) | |
tree | b4c85470214ac73ec6e4fa9981bb1f0e7b46472e /Python/import.c | |
parent | c232c9110cfefa0935cbf158e35e91746a8a9361 (diff) | |
download | cpython-git-46874c26ee1fc752e2e6930efa1d223b2351edb8.tar.gz |
bpo-39487: Merge duplicated _Py_IDENTIFIER identifiers in C code (GH-18254)
Moving repetitive `_Py_IDENTIFIER` instances to a global location helps identify them more easily in regards to sub-interpreter support.
Diffstat (limited to 'Python/import.c')
-rw-r--r-- | Python/import.c | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/Python/import.c b/Python/import.c index 2e5f78382e..9838c3fa04 100644 --- a/Python/import.c +++ b/Python/import.c @@ -39,6 +39,9 @@ extern struct _inittab _PyImport_Inittab[]; struct _inittab *PyImport_Inittab = _PyImport_Inittab; static struct _inittab *inittab_copy = NULL; +_Py_IDENTIFIER(__path__); +_Py_IDENTIFIER(__spec__); + /*[clinic input] module _imp [clinic start generated code]*/ @@ -383,7 +386,6 @@ import_ensure_initialized(PyThreadState *tstate, PyObject *mod, PyObject *name) PyInterpreterState *interp = tstate->interp; PyObject *spec; - _Py_IDENTIFIER(__spec__); _Py_IDENTIFIER(_lock_unlock_module); /* Optimization: only call _bootstrap._lock_unlock_module() if @@ -1566,9 +1568,7 @@ done: static PyObject * resolve_name(PyThreadState *tstate, PyObject *name, PyObject *globals, int level) { - _Py_IDENTIFIER(__spec__); _Py_IDENTIFIER(__package__); - _Py_IDENTIFIER(__path__); _Py_IDENTIFIER(__name__); _Py_IDENTIFIER(parent); PyObject *abs_name; @@ -1930,7 +1930,6 @@ PyImport_ImportModuleLevelObject(PyObject *name, PyObject *globals, } } else { - _Py_IDENTIFIER(__path__); PyObject *path; if (_PyObject_LookupAttrId(mod, &PyId___path__, &path) < 0) { goto error; |