Skip to content

Commit 1004157

Browse files
iritkatrielpull[bot]
authored andcommitted
gh-124013: remove _PyCompile_IsTopLevelAwait (#124014)
1 parent 254f150 commit 1004157

File tree

3 files changed

+0
-29
lines changed

3 files changed

+0
-29
lines changed

Include/internal/pycore_compile.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,10 +141,6 @@ PyObject *_PyCompile_Qualname(struct _PyCompiler *c);
141141
_PyCompile_CodeUnitMetadata *_PyCompile_Metadata(struct _PyCompiler *c);
142142
PyObject *_PyCompile_StaticAttributesAsTuple(struct _PyCompiler *c);
143143

144-
#ifndef NDEBUG
145-
int _PyCompile_IsTopLevelAwait(struct _PyCompiler *c);
146-
#endif
147-
148144
struct symtable *_PyCompile_Symtable(struct _PyCompiler *c);
149145
PySTEntryObject *_PyCompile_SymtableEntry(struct _PyCompiler *c);
150146

Python/codegen.c

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@
6565
struct _PyCompiler;
6666
typedef struct _PyCompiler compiler;
6767

68-
#define IS_TOP_LEVEL_AWAIT(C) _PyCompile_IsTopLevelAwait(C)
6968
#define INSTR_SEQUENCE(C) _PyCompile_InstrSequence(C)
7069
#define FUTURE_FEATURES(C) _PyCompile_FutureFeatures(C)
7170
#define SYMTABLE(C) _PyCompile_Symtable(C)
@@ -4497,10 +4496,6 @@ codegen_comprehension(compiler *c, expr_ty e, int type,
44974496
PyCodeObject *co = NULL;
44984497
_PyCompile_InlinedComprehensionState inline_state = {NULL, NULL, NULL, NO_LABEL};
44994498
comprehension_ty outermost;
4500-
#ifndef NDEBUG
4501-
int scope_type = SCOPE_TYPE(c);
4502-
int is_top_level_await = IS_TOP_LEVEL_AWAIT(c);
4503-
#endif
45044499
PySTEntryObject *entry = _PySymtable_Lookup(SYMTABLE(c), (void *)e);
45054500
if (entry == NULL) {
45064501
goto error;
@@ -4531,12 +4526,6 @@ codegen_comprehension(compiler *c, expr_ty e, int type,
45314526
}
45324527
Py_CLEAR(entry);
45334528

4534-
assert (!is_async_comprehension ||
4535-
type == COMP_GENEXP ||
4536-
scope_type == COMPILE_SCOPE_ASYNC_FUNCTION ||
4537-
scope_type == COMPILE_SCOPE_COMPREHENSION ||
4538-
is_top_level_await);
4539-
45404529
if (type != COMP_GENEXP) {
45414530
int op;
45424531
switch (type) {
@@ -4961,11 +4950,6 @@ codegen_visit_expr(compiler *c, expr_ty e)
49614950
ADD_YIELD_FROM(c, loc, 0);
49624951
break;
49634952
case Await_kind:
4964-
assert(IS_TOP_LEVEL_AWAIT(c) || (_PyST_IsFunctionLike(SYMTABLE_ENTRY(c)) && (
4965-
SCOPE_TYPE(c) == COMPILE_SCOPE_ASYNC_FUNCTION ||
4966-
SCOPE_TYPE(c) == COMPILE_SCOPE_COMPREHENSION
4967-
)));
4968-
49694953
VISIT(c, expr, e->v.Await.value);
49704954
ADDOP_I(c, loc, GET_AWAITABLE, 0);
49714955
ADDOP_LOAD_CONST(c, loc, Py_None);

Python/compile.c

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1242,15 +1242,6 @@ _PyCompile_Metadata(compiler *c)
12421242
return &c->u->u_metadata;
12431243
}
12441244

1245-
#ifndef NDEBUG
1246-
int
1247-
_PyCompile_IsTopLevelAwait(compiler *c)
1248-
{
1249-
return c->c_flags.cf_flags & PyCF_ALLOW_TOP_LEVEL_AWAIT &&
1250-
c->u->u_ste->ste_type == ModuleBlock;
1251-
}
1252-
#endif
1253-
12541245
// Merge *obj* with constant cache, without recursion.
12551246
int
12561247
_PyCompile_ConstCacheMergeOne(PyObject *const_cache, PyObject **obj)

0 commit comments

Comments
 (0)