8000 Refactor: replace query with parameter · python/cpython@08ffd7c · GitHub
[go: up one dir, main page]

Skip to content

Commit 08ffd7c

Browse files
Refactor: replace query with parameter
Pass state as arg to create_new_element()
1 parent 13566a3 commit 08ffd7c

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

Modules/_elementtree.c

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -297,11 +297,10 @@ clear_extra(ElementObject* self)
297297
* tag and attributes.
298298
*/
299299
LOCAL(PyObject*)
300-
create_new_element(PyObject* tag, PyObject* attrib)
300+
create_new_element(elementtreestate *st, PyObject *tag, PyObject *attrib)
301301
{
302302
ElementObject* self;
303303

304-
elementtreestate *st = ET_STATE_GLOBAL;
305304
self = PyObject_GC_New(ElementObject, st->Element_Type);
306305
if (self == NULL)
307306
return NULL;
@@ -614,7 +613,7 @@ subelement(PyObject *self, PyObject *args, PyObject *kwds)
614613
/* no attrib arg, no kwds, so no attribute */
615614
}
616615

617-
elem = create_new_element(tag, attrib);
616+
elem = create_new_element(st, tag, attrib);
618617
Py_XDECREF(attrib);
619618
if (elem == NULL)
620619
return NULL;
@@ -728,9 +727,10 @@ _elementtree_Element___copy___impl(ElementObject *self)
728727
{
729728
Py_ssize_t i;
730729
ElementObject* element;
730+
elementtreestate *st = ET_STATE_GLOBAL;
731731

732732
element = (ElementObject*) create_new_element(
733-
self->tag, self->extra ? self->extra->attrib : NULL);
733+
st, self->tag, self->extra ? self->extra->attrib : NULL);
734734
if (!element)
735735
return NULL;
736736

@@ -795,7 +795,8 @@ _elementtree_Element___deepcopy___impl(ElementObject *self, PyObject *memo)
795795
attrib = NULL;
796796
}
797797

798-
element = (ElementObject*) create_new_element(tag, attrib);
798+
elementtreestate *st = ET_STATE_GLOBAL;
799+
element = (ElementObject*) create_new_element(st, tag, attrib);
799800

800801
Py_DECREF(tag);
801802
Py_XDECREF(attrib);
@@ -818,7 +819,6 @@ _elementtree_Element___deepcopy___impl(ElementObject *self, PyObject *memo)
818819
if (element_resize(element, self->extra->length) < 0)
819820
goto error;
820821

821-
elementtreestate *st = ET_STATE_GLOBAL;
822822
for (i = 0; i < self->extra->length; i++) {
823823
PyObject* child = deepcopy(self->extra->children[i], memo);
824824
if (!child || !Element_Check(st, child)) {
@@ -1550,7 +1550,8 @@ _elementtree_Element_makeelement_impl(ElementObject *self, PyObject *tag,
15501550
if (!attrib)
15511551
return NULL;
15521552

1553-
elem = create_new_element(tag, attrib);
1553+
elementtreestate *st = ET_STATE_GLOBAL;
1554+
elem = create_new_element(st, tag, attrib);
15541555

15551556
Py_DECREF(attrib);
15561557

@@ -2614,7 +2615,7 @@ treebuilder_handle_start(TreeBuilderObject* self, PyObject* tag,
26142615
}
26152616

26162617
if (!self->element_factory) {
2617-
node = create_new_element(tag, attrib);
2618+
node = create_new_element(st, tag, attrib);
26182619
} else if (attrib == NULL) {
26192620
attrib = PyDict_New();
26202621
if (!attrib)

0 commit comments

Comments
 (0)
0