https://github.com/python/cpython/commit/8145ebea587284db3be3f152ee0298952977d6f4
commit: 8145ebea587284db3be3f152ee0298952977d6f4
branch: main
author: Irit Katriel <[email protected]>
committer: iritkatriel <[email protected]>
date: 2024-09-12T19:58:32+01:00
summary:

gh-124013: remove _PyCompile_IsTopLevelAwait (#124014)

files:
M Include/internal/pycore_compile.h
M Python/codegen.c
M Python/compile.c

diff --git a/Include/internal/pycore_compile.h 
b/Include/internal/pycore_compile.h
index 9219d4d735a576..51db6fc608caf7 100644
--- a/Include/internal/pycore_compile.h
+++ b/Include/internal/pycore_compile.h
@@ -141,10 +141,6 @@ PyObject *_PyCompile_Qualname(struct _PyCompiler *c);
 _PyCompile_CodeUnitMetadata *_PyCompile_Metadata(struct _PyCompiler *c);
 PyObject *_PyCompile_StaticAttributesAsTuple(struct _PyCompiler *c);
 
-#ifndef NDEBUG
-int _PyCompile_IsTopLevelAwait(struct _PyCompiler *c);
-#endif
-
 struct symtable *_PyCompile_Symtable(struct _PyCompiler *c);
 PySTEntryObject *_PyCompile_SymtableEntry(struct _PyCompiler *c);
 
diff --git a/Python/codegen.c b/Python/codegen.c
index fd2260a538f76d..9ce4e1fb1f6c92 100644
--- a/Python/codegen.c
+++ b/Python/codegen.c
@@ -65,7 +65,6 @@
 struct _PyCompiler;
 typedef struct _PyCompiler compiler;
 
-#define IS_TOP_LEVEL_AWAIT(C) _PyCompile_IsTopLevelAwait(C)
 #define INSTR_SEQUENCE(C) _PyCompile_InstrSequence(C)
 #define FUTURE_FEATURES(C) _PyCompile_FutureFeatures(C)
 #define SYMTABLE(C) _PyCompile_Symtable(C)
@@ -4497,10 +4496,6 @@ codegen_comprehension(compiler *c, expr_ty e, int type,
     PyCodeObject *co = NULL;
     _PyCompile_InlinedComprehensionState inline_state = {NULL, NULL, NULL, 
NO_LABEL};
     comprehension_ty outermost;
-#ifndef NDEBUG
-    int scope_type = SCOPE_TYPE(c);
-    int is_top_level_await = IS_TOP_LEVEL_AWAIT(c);
-#endif
     PySTEntryObject *entry = _PySymtable_Lookup(SYMTABLE(c), (void *)e);
     if (entry == NULL) {
         goto error;
@@ -4531,12 +4526,6 @@ codegen_comprehension(compiler *c, expr_ty e, int type,
     }
     Py_CLEAR(entry);
 
-    assert (!is_async_comprehension ||
-            type == COMP_GENEXP ||
-            scope_type == COMPILE_SCOPE_ASYNC_FUNCTION ||
-            scope_type == COMPILE_SCOPE_COMPREHENSION ||
-            is_top_level_await);
-
     if (type != COMP_GENEXP) {
         int op;
         switch (type) {
@@ -4961,11 +4950,6 @@ codegen_visit_expr(compiler *c, expr_ty e)
         ADD_YIELD_FROM(c, loc, 0);
         break;
     case Await_kind:
-        assert(IS_TOP_LEVEL_AWAIT(c) || 
(_PyST_IsFunctionLike(SYMTABLE_ENTRY(c)) && (
-            SCOPE_TYPE(c) == COMPILE_SCOPE_ASYNC_FUNCTION ||
-            SCOPE_TYPE(c) == COMPILE_SCOPE_COMPREHENSION
-        )));
-
         VISIT(c, expr, e->v.Await.value);
         ADDOP_I(c, loc, GET_AWAITABLE, 0);
         ADDOP_LOAD_CONST(c, loc, Py_None);
diff --git a/Python/compile.c b/Python/compile.c
index 72399c758d51e8..d54c320babc2b7 100644
--- a/Python/compile.c
+++ b/Python/compile.c
@@ -1242,15 +1242,6 @@ _PyCompile_Metadata(compiler *c)
     return &c->u->u_metadata;
 }
 
-#ifndef NDEBUG
-int
-_PyCompile_IsTopLevelAwait(compiler *c)
-{
-    return c->c_flags.cf_flags & PyCF_ALLOW_TOP_LEVEL_AWAIT &&
-           c->u->u_ste->ste_type == ModuleBlock;
-}
-#endif
-
 // Merge *obj* with constant cache, without recursion.
 int
 _PyCompile_ConstCacheMergeOne(PyObject *const_cache, PyObject **obj)

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]

Reply via email to