diff options
author | Eric Snow <ericsnowcurrently@gmail.com> | 2023-02-15 15:32:31 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-02-15 15:32:31 -0700 |
commit | b2fc5492789623d656953d458f3eeaac03c1ef56 (patch) | |
tree | ef2614bd53b935d48170ae2d936ca873ffc92cfc /Python/ceval.c | |
parent | c1ce0d178fe57b50f37578b285a343d77485ac02 (diff) | |
download | cpython-git-b2fc5492789623d656953d458f3eeaac03c1ef56.tar.gz |
gh-101758: Clean Up Uses of Import State (gh-101919)
This change is almost entirely moving code around and hiding import state behind internal API. We introduce no changes to behavior, nor to non-internal API. (Since there was already going to be a lot of churn, I took this as an opportunity to re-organize import.c into topically-grouped sections of code.) The motivation is to simplify a number of upcoming changes.
Specific changes:
* move existing import-related code to import.c, wherever possible
* add internal API for interacting with import state (both global and per-interpreter)
* use only API outside of import.c (to limit churn there when changing the location, etc.)
* consolidate the import-related state of PyInterpreterState into a single struct field (this changes layout slightly)
* add macros for import state in import.c (to simplify changing the location)
* group code in import.c into sections
*remove _PyState_AddModule()
https://github.com/python/cpython/issues/101758
Diffstat (limited to 'Python/ceval.c')
-rw-r--r-- | Python/ceval.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/Python/ceval.c b/Python/ceval.c index 611d62b0eb..09fd2f2926 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -2688,7 +2688,7 @@ import_name(PyThreadState *tstate, _PyInterpreterFrame *frame, } PyObject *locals = frame->f_locals; /* Fast path for not overloaded __import__. */ - if (import_func == tstate->interp->import_func) { + if (_PyImport_IsDefaultImportFunc(tstate->interp, import_func)) { int ilevel = _PyLong_AsInt(level); if (ilevel == -1 && _PyErr_Occurred(tstate)) { return NULL; |