Skip to content

Commit 3408c11

Browse files
committed
CR feedback
1 parent 840c35f commit 3408c11

File tree

3 files changed

+12
-18
lines changed

3 files changed

+12
-18
lines changed

Python/codegen.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -705,16 +705,19 @@ codegen_leave_annotations_scope(compiler *c, location loc)
705705
// co->co_localsplusnames = ("format", *co->co_localsplusnames[1:])
706706
const Py_ssize_t size = PyObject_Size(co->co_localsplusnames);
707707
if (size == -1) {
708+
Py_DECREF(co);
708709
return ERROR;
709710
}
710711
PyObject *new_names = PyTuple_New(size);
711712
if (new_names == NULL) {
713+
Py_DECREF(co);
712714
return ERROR;
713715
}
714716
PyTuple_SET_ITEM(new_names, 0, Py_NewRef(&_Py_ID(format)));
715717
for (int i = 1; i < size; i++) {
716718
PyObject *item = PyTuple_GetItem(co->co_localsplusnames, i);
717719
if (item == NULL) {
720+
Py_DECREF(co);
718721
Py_DECREF(new_names);
719722
return ERROR;
720723
}
@@ -724,9 +727,6 @@ codegen_leave_annotations_scope(compiler *c, location loc)
724727
Py_SETREF(co->co_localsplusnames, new_names);
725728

726729
_PyCompile_ExitScope(c);
727-
if (co == NULL) {
728-
return ERROR;
729-
}
730730
int ret = codegen_make_closure(c, loc, co, 0);
731731
Py_DECREF(co);
732732
RETURN_IF_ERROR(ret);
@@ -2941,9 +2941,9 @@ codegen_stmt_expr(compiler *c, location loc, expr_ty value)
29412941
#define CODEGEN_COND_BLOCK(FUNC, C, S) \
29422942
do { \
29432943
_PyCompile_EnterConditionalBlock((C)); \
2944-
int __result = FUNC((C), (S)); \
2944+
int result = FUNC((C), (S)); \
29452945
_PyCompile_LeaveConditionalBlock((C)); \
2946-
return __result; \
2946+
return result; \
29472947
} while(0)
29482948

29492949
static int

Python/compile.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ struct compiler_unit {
5555
PyObject *u_private; /* for private name mangling */
5656
PyObject *u_static_attributes; /* for class: attributes accessed via self.X */
5757
PyObject *u_deferred_annotations; /* AnnAssign nodes deferred to the end of compilation */
58-
PyObject *u_conditional_annotation_indices; /* indices of annotations that are conditionally executed (or -1) */
59-
int u_next_conditional_annotation_index; /* index of the next conditional annotation */
58+
PyObject *u_conditional_annotation_indices; /* indices of annotations that are conditionally executed (or -1 for unconditional annotations) */
59+
long u_next_conditional_annotation_index; /* index of the next conditional annotation */
6060

6161
instr_sequence *u_instr_sequence; /* codegen output */
6262

Python/symtable.c

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1735,11 +1735,11 @@ symtable_enter_type_param_block(struct symtable *st, identifier name,
17351735
} while(0)
17361736

17371737
#define ENTER_CONDITIONAL_BLOCK(ST) \
1738-
int __in_conditional_block = (ST)->st_cur->ste_in_conditional_block; \
1738+
int in_conditional_block = (ST)->st_cur->ste_in_conditional_block; \
17391739
(ST)->st_cur->ste_in_conditional_block = 1;
17401740

17411741
#define LEAVE_CONDITIONAL_BLOCK(ST) \
1742-
(ST)->st_cur->ste_in_conditional_block = __in_conditional_block;
1742+
(ST)->st_cur->ste_in_conditional_block = in_conditional_block;
17431743

17441744
#define ENTER_RECURSIVE() \
17451745
if (Py_EnterRecursiveCall(" during compilation")) { \
@@ -2728,10 +2728,9 @@ symtable_visit_params(struct symtable *st, asdl_arg_seq *args)
27282728
static int
27292729
symtable_visit_annotation(struct symtable *st, expr_ty annotation, void *key)
27302730
{
2731-
bool new_conditional = (st->st_cur->ste_type == ClassBlock || st->st_cur->ste_type == ModuleBlock)
2732-
&& st->st_cur->ste_in_conditional_block
2733-
&& !st->st_cur->ste_has_conditional_annotations;
2734-
if (new_conditional) {
2731+
if ((st->st_cur->ste_type == ClassBlock || st->st_cur->ste_type == ModuleBlock)
2732+
&& st->st_cur->ste_in_conditional_block
2733+
&& !st->st_cur->ste_has_conditional_annotations) {
27352734
st->st_cur->ste_has_conditional_annotations = 1;
27362735
if (!symtable_add_def(st, &_Py_ID(__conditional_annotations__), USE, LOCATION(annotation))) {
27372736
return 0;
@@ -2759,11 +2758,6 @@ symtable_visit_annotation(struct symtable *st, expr_ty annotation, void *key)
27592758
return 0;
27602759
}
27612760
}
2762-
if (new_conditional) {
2763-
if (!symtable_add_def(st, &_Py_ID(__conditional_annotations__), USE, LOCATION(annotation))) {
2764-
return 0;
2765-
}
2766-
}
27672761
VISIT(st, expr, annotation);
27682762
if (!symtable_exit_block(st)) {
27692763
return 0;

0 commit comments

Comments
 (0)