Skip to content

Commit c12fc1c

Browse files
committed
Remove unnecessary goto, cleanup code
1 parent cd12313 commit c12fc1c

File tree

2 files changed

+11
-14
lines changed

2 files changed

+11
-14
lines changed

Objects/funcobject.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -423,13 +423,13 @@ func_get_annotations(PyFunctionObject *op, void *Py_UNUSED(ignored))
423423
op->func_annotations = PyDict_New();
424424
if (op->func_annotations == NULL)
425425
return NULL;
426-
427426
}
428427
if (PyTuple_CheckExact(op->func_annotations)) {
429428
PyObject *ann_tuple = op->func_annotations;
430429
PyObject *ann_dict = PyDict_New();
431-
if (ann_dict == NULL)
430+
if (ann_dict == NULL) {
432431
return NULL;
432+
}
433433

434434
assert(PyTuple_GET_SIZE(ann_tuple) % 2 == 0);
435435

Python/compile.c

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2072,39 +2072,35 @@ compiler_visit_annotations(struct compiler *c, arguments_ty args,
20722072
Py_ssize_t annotations_len = 0;
20732073

20742074
if (!compiler_visit_argannotations(c, args->args, &annotations_len))
2075-
goto error;
2075+
return 0;
20762076
if (!compiler_visit_argannotations(c, args->posonlyargs, &annotations_len))
2077-
goto error;
2077+
return 0;
20782078
if (args->vararg && args->vararg->annotation &&
20792079
!compiler_visit_argannotation(c, args->vararg->arg,
20802080
args->vararg->annotation, &annotations_len))
2081-
goto error;
2081+
return 0;
20822082
if (!compiler_visit_argannotations(c, args->kwonlyargs, &annotations_len))
2083-
goto error;
2083+
return 0;
20842084
if (args->kwarg && args->kwarg->annotation &&
20852085
!compiler_visit_argannotation(c, args->kwarg->arg,
20862086
args->kwarg->annotation, &annotations_len))
2087-
goto error;
2087+
return 0;
20882088

20892089
if (!return_str) {
20902090
return_str = PyUnicode_InternFromString("return");
20912091
if (!return_str)
2092-
goto error;
2092+
return 0;
20932093
}
20942094
if (!compiler_visit_argannotation(c, return_str, returns, &annotations_len)) {
2095-
goto error;
2095+
return 0;
20962096
}
20972097

20982098
if (annotations_len) {
20992099
ADDOP_I(c, BUILD_TUPLE, annotations_len);
21002100
return 1;
21012101
}
2102-
else {
2103-
return -1;
2104-
}
21052102

2106-
error:
2107-
return 0;
2103+
return -1;
21082104
}
21092105

21102106
static int
@@ -6449,3 +6445,4 @@ PyCode_Optimize(PyObject *code, PyObject* Py_UNUSED(consts),
64496445
Py_INCREF(code);
64506446
return code;
64516447
}
6448+

0 commit comments

Comments
 (0)