Skip to content

Commit 47235c6

Browse files
DinoVmeta-codesync[bot]
authored andcommitted
Use META_PYTHON for MetaPython specific features
Summary: Currently we use ENABLE_LAZY_IMPORTs to toggle lazy imports. That works great but I'm about to need a 2nd ifdef... rather than adding a new thing and needing to update a lot of places let's use a single ifdef for meta Python. Reviewed By: alexmalyshev, yoney Differential Revision: D87464662 fbshipit-source-id: bb4c5e1250b389fb9074ff4a64c23fd975702b29
1 parent 4621dee commit 47235c6

36 files changed

Lines changed: 192 additions & 192 deletions

Include/cpython/compile.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
#define PyCF_ALLOW_TOP_LEVEL_AWAIT 0x2000
2121
#define PyCF_ALLOW_INCOMPLETE_INPUT 0x4000
2222
#define PyCF_OPTIMIZED_AST (0x8000 | PyCF_ONLY_AST)
23-
#ifdef ENABLE_LAZY_IMPORTS
23+
#ifdef META_PYTHON
2424
#define PyCF_DISABLE_LAZY_IMPORTS 0x10000
2525
#define PyCF_COMPILE_MASK (PyCF_ONLY_AST | PyCF_ALLOW_TOP_LEVEL_AWAIT | \
2626
PyCF_TYPE_COMMENTS | PyCF_DONT_IMPLY_DEDENT | \

Include/cpython/dictobject.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ Py_DEPRECATED(3.14) PyAPI_FUNC(PyObject *) _PyDict_Pop(
7575
PyObject *key,
7676
PyObject *default_value);
7777

78-
#ifdef ENABLE_LAZY_IMPORTS
78+
#ifdef META_PYTHON
7979
PyAPI_FUNC(int) _PyDict_NextKeepLazy(
8080
PyObject *mp, Py_ssize_t *pos, PyObject **key, PyObject **value);
8181
PyAPI_FUNC(int) PyDict_NextWithError(

Include/cpython/import.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# error "this header file must not be included directly"
33
#endif
44

5-
#ifdef ENABLE_LAZY_IMPORTS
5+
#ifdef META_PYTHON
66
PyAPI_FUNC(PyObject *) _PyImport_GetModule(PyThreadState *tstate, PyObject *name);
77
PyAPI_FUNC(PyObject *) PyImport_SetLazyImports(
88
PyObject *enabled, PyObject *excluding, PyObject *eager);

Include/cpython/initconfig.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ typedef struct PyConfig {
242242
wchar_t *run_presite;
243243
#endif
244244

245-
#ifdef ENABLE_LAZY_IMPORTS
245+
#ifdef META_PYTHON
246246
int lazy_imports;
247247
#endif
248248
} PyConfig;

Include/cpython/pyerrors.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,6 @@ PyAPI_DATA(PyObject *) PyExc_PythonFinalizationError;
131131

132132
#define Py_FatalError(message) _Py_FatalErrorFunc(__func__, (message))
133133

134-
#ifdef ENABLE_LAZY_IMPORTS
134+
#ifdef META_PYTHON
135135
PyAPI_DATA(PyObject *) PyExc_ImportCycleError;
136136
#endif

Include/internal/pycore_ceval.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ extern void _PyEval_Fini(void);
8888

8989

9090
extern PyObject* _PyEval_GetBuiltins(PyThreadState *tstate);
91-
#ifdef ENABLE_LAZY_IMPORTS
91+
#ifdef META_PYTHON
9292
extern PyObject* _PyEval_GetGlobals(PyThreadState *tstate);
9393
#endif
9494

Include/internal/pycore_compile.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ int _PyCompile_ResolveNameop(struct _PyCompiler *c, PyObject *mangled, int scope
151151
int _PyCompile_IsInteractiveTopLevel(struct _PyCompiler *c);
152152
int _PyCompile_IsInInlinedComp(struct _PyCompiler *c);
153153
int _PyCompile_ScopeType(struct _PyCompiler *c);
154-
#ifdef ENABLE_LAZY_IMPORTS
154+
#ifdef META_PYTHON
155155
int _PyCompile_NFBlocks(struct _PyCompiler *c);
156156
int _PyCompile_CFFlags(struct _PyCompiler *c);
157157
#endif

Include/internal/pycore_dict.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ extern void _PyDictKeys_DecRef(PyDictKeysObject *keys);
117117
*/
118118
extern Py_ssize_t _Py_dict_lookup(PyDictObject *mp, PyObject *key, Py_hash_t hash, PyObject **value_addr);
119119

120-
#ifdef ENABLE_LAZY_IMPORTS
120+
#ifdef META_PYTHON
121121
/* _Py_dict_lookup_keep_lazy() is the same as _Py_dict_lookup(), but keeps lazy objects unresolved */
122122
extern Py_ssize_t _Py_dict_lookup_keep_lazy(PyDictObject *mp, PyObject *key, Py_hash_t hash, PyObject **value_addr);
123123
extern int _PyDict_GetItemRefKeepLazy(PyObject *, PyObject *, PyObject **);
@@ -173,7 +173,7 @@ PyAPI_FUNC(void) _PyDict_EnsureSharedOnRead(PyDictObject *mp);
173173
#define DKIX_DUMMY (-2) /* Used internally */
174174
#define DKIX_ERROR (-3)
175175
#define DKIX_KEY_CHANGED (-4) /* Used internally */
176-
#ifdef ENABLE_LAZY_IMPORTS
176+
#ifdef META_PYTHON
177177
#define DKIX_VALUE_ERROR (-5) /* Used internally */
178178
#endif
179179

@@ -187,7 +187,7 @@ typedef enum {
187187
#define DICT_KEYS_KIND_MASK 0x03
188188
#define DICT_KEYS_LAZY_IMPORTS_MASK 0x80
189189

190-
#ifdef ENABLE_LAZY_IMPORTS
190+
#ifdef META_PYTHON
191191
#define LOAD_SHARED_UCHAR(obj) _Py_atomic_load_uchar_acquire(&obj)
192192
#define STORE_SHARED_UCHAR(obj, value) _Py_atomic_store_uchar_release(&obj, value)
193193
#define DK_KIND(dk) (LOAD_SHARED_UCHAR(dk->dk_kind) & DICT_KEYS_KIND_MASK)

Include/internal/pycore_import.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ extern const struct _module_alias * _PyImport_FrozenAliases;
117117
extern int _PyImport_CheckSubinterpIncompatibleExtensionAllowed(
118118
const char *name);
119119

120-
#ifdef ENABLE_LAZY_IMPORTS
120+
#ifdef META_PYTHON
121121
PyAPI_FUNC(PyObject *) _PyImport_ImportName(PyThreadState *tstate,
122122
PyObject *builtins,
123123
PyObject *globals,

Include/internal/pycore_interp_structs.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -970,7 +970,7 @@ struct _is {
970970
// _initial_thread should be the last field of PyInterpreterState.
971971
// See https://github.com/python/cpython/issues/127117.
972972

973-
#ifdef ENABLE_LAZY_IMPORTS
973+
#ifdef META_PYTHON
974974
// Lazy Imports
975975
int lazy_imports; /* whether lazy imports was enabled at runtime */
976976
PyObject *lazy_import_verbose_seen;

0 commit comments

Comments
 (0)