Skip to content

Commit 8f1758b

Browse files
Refactor per Serhiy's reqyuest
1 parent 230b348 commit 8f1758b

1 file changed

Lines changed: 5 additions & 8 deletions

File tree

Modules/_elementtree.c

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -812,7 +812,7 @@ _elementtree_Element___deepcopy___impl(ElementObject *self, PyObject *memo)
812812
/*[clinic end generated code: output=eefc3df50465b642 input=a2d40348c0aade10]*/
813813
{
814814
Py_ssize_t i;
815-
ElementObject* element;
815+
ElementObject* element = NULL;
816816
PyObject* tag;
817817
PyObject* attrib;
818818
PyObject* text;
@@ -829,16 +829,14 @@ _elementtree_Element___deepcopy___impl(ElementObject *self, PyObject *memo)
829829
// of the object to copy so to avoid use-after-frees.
830830
tag = deepcopy(st, self->tag, memo);
831831
if (!tag) {
832-
_Py_LeaveRecursiveCall();
833-
return NULL;
832+
goto error;
834833
}
835834

836835
if (self->extra && self->extra->attrib) {
837836
attrib = deepcopy(st, self->extra->attrib, memo);
838837
if (!attrib) {
839838
Py_DECREF(tag);
840-
_Py_LeaveRecursiveCall();
841-
return NULL;
839+
goto error;
842840
}
843841
} else {
844842
attrib = NULL;
@@ -850,8 +848,7 @@ _elementtree_Element___deepcopy___impl(ElementObject *self, PyObject *memo)
850848
Py_XDECREF(attrib);
851849

852850
if (!element) {
853-
_Py_LeaveRecursiveCall();
854-
return NULL;
851+
goto error;
855852
}
856853

857854
text = deepcopy(st, JOIN_OBJ(self->text), memo);
@@ -919,7 +916,7 @@ _elementtree_Element___deepcopy___impl(ElementObject *self, PyObject *memo)
919916

920917
error:
921918
_Py_LeaveRecursiveCall();
922-
Py_DECREF(element);
919+
Py_XDECREF(element);
923920
return NULL;
924921
}
925922

0 commit comments

Comments
 (0)