Skip to content

Commit b7c7f71

Browse files
committed
avoid creating useless extras
1 parent 4509a33 commit b7c7f71

File tree

1 file changed

+3
-11
lines changed

1 file changed

+3
-11
lines changed

Modules/_elementtree.c

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1875,19 +1875,11 @@ element_ass_subscr(PyObject *op, PyObject *item, PyObject *value)
18751875
return -1;
18761876
}
18771877

1878-
// Since PySlice_Unpack() may clear 'self->extra', we need
1879-
// to ensure that it exists now (using a slice for assignment
1880-
// should not raise IndexError).
1881-
//
1882-
// See https://github.com/python/cpython/issues/143200.
1883-
if (self->extra == NULL) {
1884-
if (create_extra(self, NULL) < 0) {
1885-
return -1;
1886-
}
1887-
}
1888-
18891878
if (value == NULL) {
18901879
/* Delete slice */
1880+
if (self->extra == NULL) {
1881+
return 0;
1882+
}
18911883
slicelen = PySlice_AdjustIndices(self->extra->length, &start, &stop,
18921884
step);
18931885
if (slicelen <= 0)

0 commit comments

Comments
 (0)