Skip to content

Commit e0249cc

Browse files
Apply suggestions from code review
Co-authored-by: Bénédikt Tran <[email protected]>
1 parent ed79a88 commit e0249cc

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

Python/codegen.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -737,7 +737,7 @@ static int
737737
codegen_deferred_annotations_body(compiler *c, location loc,
738738
PyObject *deferred_anno, PyObject *conditional_annotation_indices, int scope_type)
739739
{
740-
Py_ssize_t annotations_len = PyList_Size(deferred_anno);
740+
Py_ssize_t annotations_len = PyList_GET_SIZE(deferred_anno);
741741

742742
assert(PyList_CheckExact(conditional_annotation_indices));
743743
assert(annotations_len == PyList_Size(conditional_annotation_indices));
@@ -756,7 +756,7 @@ codegen_deferred_annotations_body(compiler *c, location loc,
756756
}
757757
PyObject *cond_index = PyList_GET_ITEM(conditional_annotation_indices, i);
758758
assert(PyLong_CheckExact(cond_index));
759-
long idx = PyLong_AsLong(cond_index);
759+
long idx = PyLong_AS_LONG(cond_index);
760760
NEW_JUMP_TARGET_LABEL(c, not_set);
761761

762762
if (idx != -1) {

Python/compile.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1163,11 +1163,9 @@ _PyCompile_AddDeferredAnnotation(compiler *c, stmt_ty s,
11631163
return ERROR;
11641164
}
11651165
}
1166-
if (PyList_Append(c->u->u_conditional_annotation_indices, index) < 0) {
1167-
Py_DECREF(index);
1168-
return ERROR;
1169-
}
1166+
int rc = PyList_Append(c->u->u_conditional_annotation_indices, index);
11701167
Py_DECREF(index);
1168+
RETURN_IF_ERROR(rc);
11711169
return SUCCESS;
11721170
}
11731171

0 commit comments

Comments
 (0)