Skip to content

Commit 83b8a78

Browse files
committed
gh-152298: Preserve lazy import global bindings
1 parent f1beae8 commit 83b8a78

12 files changed

Lines changed: 294 additions & 669 deletions

File tree

Include/internal/pycore_import.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,8 @@ extern PyObject * _PyImport_GetAbsName(
3939
// Symbol is exported for the JIT on Windows builds.
4040
PyAPI_FUNC(PyObject *) _PyImport_LoadLazyImportTstate(
4141
PyThreadState *tstate, PyObject *lazy_import);
42-
// Returns 1 with a new reference in result, 0 if not pending, or -1 on error.
43-
extern int _PyImport_TryLoadLazySubmodule(
44-
PyObject *mod_name, PyObject *attr_name, PyObject *mod_dict,
45-
PyObject **result);
42+
extern PyObject * _PyImport_TryLoadLazySubmodule(
43+
PyObject *mod_name, PyObject *attr_name);
4644
extern PyObject * _PyImport_LazyImportModuleLevelObject(
4745
PyThreadState *tstate, PyObject *name, PyObject *builtins,
4846
PyObject *globals, PyObject *locals, PyObject *fromlist, int level);

Include/internal/pycore_lazyimportobject.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,19 @@ typedef struct {
1919
PyObject *lz_builtins;
2020
PyObject *lz_from;
2121
PyObject *lz_attr;
22+
// Protected by the lazy object lock.
2223
PyObject *lz_globals;
2324
PyObject *lz_key;
24-
PyObject *lz_resolved; // Protected by the lazy object lock.
25-
Py_hash_t lz_key_hash;
25+
PyObject *lz_resolved;
2626
// Frame information for the original import location.
2727
PyCodeObject *lz_code; // Code object where the lazy import was created.
2828
int lz_instr_offset; // Instruction offset where the lazy import was created.
2929
} PyLazyImportObject;
3030

3131

3232
PyAPI_FUNC(PyObject *) _PyLazyImport_GetName(PyObject *lazy_import);
33-
PyAPI_FUNC(PyObject *) _PyLazyImport_GetResolved(PyObject *lazy_import);
34-
PyAPI_FUNC(int) _PyLazyImport_FinishResolve(
33+
extern PyObject * _PyLazyImport_GetResolved(PyObject *lazy_import);
34+
extern int _PyLazyImport_FinishResolve(
3535
PyObject *lazy_import, PyObject *resolved);
3636
PyAPI_FUNC(int) _PyLazyImport_ReplaceDictItemIfCurrent(
3737
PyObject *lazy_import, PyObject *dict, PyObject *name,

0 commit comments

Comments
 (0)