diff --git a/Include/internal/pycore_import.h b/Include/internal/pycore_import.h index c0db135a4e4..b1948df4fbf 100644 --- a/Include/internal/pycore_import.h +++ b/Include/internal/pycore_import.h @@ -36,7 +36,8 @@ extern PyObject * _PyImport_ResolveName(PyThreadState *tstate, PyObject *name, PyObject *globals, int level); extern PyObject * _PyImport_GetAbsName(PyThreadState *tstate, PyObject *name, PyObject *globals, int level); -extern PyObject * +// Symbol is exported for the JIT on Windows builds. +PyAPI_FUNC(PyObject *) _PyImport_LoadLazyImportTstate(PyThreadState *tstate, PyObject *lazy_import); extern PyObject * _PyImport_LazyImportModuleLevelObject(PyThreadState *tstate, PyObject *name, PyObject *builtins, PyObject *globals, diff --git a/Include/internal/pycore_lazyimportobject.h b/Include/internal/pycore_lazyimportobject.h index 88dad3e7291..513daeffd91 100644 --- a/Include/internal/pycore_lazyimportobject.h +++ b/Include/internal/pycore_lazyimportobject.h @@ -2,12 +2,17 @@ /* Lazy object interface */ -#ifndef Py_LAZYIMPORTOBJECT_H -#define Py_LAZYIMPORTOBJECT_H +#ifndef Py_INTERNAL_LAZYIMPORTOBJECT_H +#define Py_INTERNAL_LAZYIMPORTOBJECT_H + #ifdef __cplusplus extern "C" { #endif +#ifndef Py_BUILD_CORE +# error "this header requires Py_BUILD_CORE define" +#endif + PyAPI_DATA(PyTypeObject) PyLazyImport_Type; #define PyLazyImport_CheckExact(op) Py_IS_TYPE((op), &PyLazyImport_Type) @@ -28,4 +33,4 @@ PyAPI_FUNC(PyObject *) _PyLazyImport_New(PyObject *import_func, PyObject *from, #ifdef __cplusplus } #endif -#endif /* !Py_LAZYIMPORTOBJECT_H */ +#endif /* !Py_INTERNAL_LAZYIMPORTOBJECT_H */ diff --git a/Python/bytecodes.c b/Python/bytecodes.c index e405a67625b..10b636844d8 100644 --- a/Python/bytecodes.c +++ b/Python/bytecodes.c @@ -11,12 +11,15 @@ #include "pycore_audit.h" // _PySys_Audit() #include "pycore_backoff.h" #include "pycore_cell.h" // PyCell_GetRef() +#include "pycore_ceval.h" // _PyEval_LazyImportName(), _PyEval_LazyImportFrom() #include "pycore_code.h" #include "pycore_emscripten_signal.h" // _Py_CHECK_EMSCRIPTEN_SIGNALS #include "pycore_function.h" +#include "pycore_import.h" // _PyImport_LoadLazyImportTstate() #include "pycore_instruments.h" #include "pycore_interpolation.h" // _PyInterpolation_Build() #include "pycore_intrinsics.h" +#include "pycore_lazyimportobject.h" // PyLazyImport_CheckExact() #include "pycore_long.h" // _PyLong_ExactDealloc(), _PyLong_GetZero() #include "pycore_moduleobject.h" // PyModuleObject #include "pycore_object.h" // _PyObject_GC_TRACK() @@ -2939,7 +2942,7 @@ dummy_func( b = res ? PyStackRef_True : PyStackRef_False; } - inst(IMPORT_NAME, (level, fromlist -- res)) { + inst(IMPORT_NAME, (level, fromlist -- res)) { PyObject *name = GETITEM(FRAME_CO_NAMES, oparg >> 2); PyObject *res_o; if (!(oparg & 0x02)) { diff --git a/Python/jit.c b/Python/jit.c index 47d3d7a5d27..18f4ad868f8 100644 --- a/Python/jit.c +++ b/Python/jit.c @@ -11,9 +11,11 @@ #include "pycore_floatobject.h" #include "pycore_frame.h" #include "pycore_function.h" +#include "pycore_import.h" #include "pycore_interpframe.h" #include "pycore_interpolation.h" #include "pycore_intrinsics.h" +#include "pycore_lazyimportobject.h" #include "pycore_list.h" #include "pycore_long.h" #include "pycore_opcode_metadata.h" diff --git a/Tools/jit/template.c b/Tools/jit/template.c index 0167f1b0ae5..c2f17a89b44 100644 --- a/Tools/jit/template.c +++ b/Tools/jit/template.c @@ -12,9 +12,11 @@ #include "pycore_frame.h" #include "pycore_function.h" #include "pycore_genobject.h" +#include "pycore_import.h" #include "pycore_interpframe.h" #include "pycore_interpolation.h" #include "pycore_intrinsics.h" +#include "pycore_lazyimportobject.h" #include "pycore_jit.h" #include "pycore_list.h" #include "pycore_long.h"