summaryrefslogtreecommitdiffstats
path: root/Parser/asdl_c.py
diff options
context:
space:
mode:
Diffstat (limited to 'Parser/asdl_c.py')
-rwxr-xr-xParser/asdl_c.py34
1 files changed, 4 insertions, 30 deletions
diff --git a/Parser/asdl_c.py b/Parser/asdl_c.py
index e96f1f3..aefea12 100755
--- a/Parser/asdl_c.py
+++ b/Parser/asdl_c.py
@@ -1373,17 +1373,13 @@ def generate_ast_fini(module_state, f):
f.write(textwrap.dedent("""
void _PyAST_Fini(PyInterpreterState *interp)
{
- #ifdef Py_BUILD_CORE
struct ast_state *state = &interp->ast;
- #else
- struct ast_state *state = &global_ast_state;
- #endif
"""))
for s in module_state:
f.write(" Py_CLEAR(state->" + s + ');\n')
f.write(textwrap.dedent("""
- #if defined(Py_BUILD_CORE) && !defined(NDEBUG)
+ #if !defined(NDEBUG)
state->initialized = -1;
#else
state->initialized = 0;
@@ -1428,24 +1424,15 @@ def generate_module_def(mod, f, internal_h):
generate_ast_state(module_state, internal_h)
print(textwrap.dedent(f"""
- #ifdef Py_BUILD_CORE
- # include "pycore_ast_state.h" // struct ast_state
- # include "pycore_interp.h" // _PyInterpreterState.ast
- # include "pycore_pystate.h" // _PyInterpreterState_GET()
- #else
- """).strip(), file=f)
-
- generate_ast_state(module_state, f)
-
- print(textwrap.dedent(f"""
- #endif // Py_BUILD_CORE
+ #include "pycore_ast_state.h" // struct ast_state
+ #include "pycore_interp.h" // _PyInterpreterState.ast
+ #include "pycore_pystate.h" // _PyInterpreterState_GET()
""").rstrip(), file=f)
f.write("""
// Forward declaration
static int init_types(struct ast_state *state);
-#ifdef Py_BUILD_CORE
static struct ast_state*
get_ast_state(void)
{
@@ -1456,19 +1443,6 @@ get_ast_state(void)
}
return state;
}
-#else
-static struct ast_state global_ast_state;
-
-static struct ast_state*
-get_ast_state(void)
-{
- struct ast_state *state = &global_ast_state;
- if (!init_types(state)) {
- return NULL;
- }
- return state;
-}
-#endif // Py_BUILD_CORE
""")
# f-string for {mod.name}