mirror of
https://github.com/python/cpython.git
synced 2025-10-19 16:03:42 +00:00
gh-138349: Fix crash when combining module-level annotation and listcomp (#138363)
This commit is contained in:
parent
f5fa336579
commit
7a6fd4a45d
4 changed files with 48 additions and 5 deletions
|
@ -5477,10 +5477,12 @@ codegen_annassign(compiler *c, stmt_ty s)
|
|||
RETURN_IF_ERROR(_PyCompile_AddDeferredAnnotation(
|
||||
c, s, &conditional_annotation_index));
|
||||
if (conditional_annotation_index != NULL) {
|
||||
ADDOP_NAME(
|
||||
c, loc,
|
||||
SCOPE_TYPE(c) == COMPILE_SCOPE_CLASS ? LOAD_DEREF : LOAD_NAME,
|
||||
&_Py_ID(__conditional_annotations__), cellvars);
|
||||
if (SCOPE_TYPE(c) == COMPILE_SCOPE_CLASS) {
|
||||
ADDOP_NAME(c, loc, LOAD_DEREF, &_Py_ID(__conditional_annotations__), cellvars);
|
||||
}
|
||||
else {
|
||||
ADDOP_NAME(c, loc, LOAD_NAME, &_Py_ID(__conditional_annotations__), names);
|
||||
}
|
||||
ADDOP_LOAD_CONST_NEW(c, loc, conditional_annotation_index);
|
||||
ADDOP_I(c, loc, SET_ADD, 1);
|
||||
ADDOP(c, loc, POP_TOP);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue