@@ -297,11 +297,10 @@ clear_extra(ElementObject* self)
297
297
* tag and attributes.
298
298
*/
299
299
LOCAL (PyObject * )
300
- create_new_element (PyObject * tag , PyObject * attrib )
300
+ create_new_element (elementtreestate * st , PyObject * tag , PyObject * attrib )
301
301
{
302
302
ElementObject * self ;
303
303
304
- elementtreestate * st = ET_STATE_GLOBAL ;
305
304
self = PyObject_GC_New (ElementObject , st -> Element_Type );
306
305
if (self == NULL )
307
306
return NULL ;
@@ -614,7 +613,7 @@ subelement(PyObject *self, PyObject *args, PyObject *kwds)
614
613
/* no attrib arg, no kwds, so no attribute */
615
614
}
616
615
617
- elem = create_new_element (tag , attrib );
616
+ elem = create_new_element (st , tag , attrib );
618
617
Py_XDECREF (attrib );
619
618
if (elem == NULL )
620
619
return NULL ;
@@ -728,9 +727,10 @@ _elementtree_Element___copy___impl(ElementObject *self)
728
727
{
729
728
Py_ssize_t i ;
730
729
ElementObject * element ;
730
+ elementtreestate * st = ET_STATE_GLOBAL ;
731
731
732
732
element = (ElementObject * ) create_new_element (
733
- self -> tag , self -> extra ? self -> extra -> attrib : NULL );
733
+ st , self -> tag , self -> extra ? self -> extra -> attrib : NULL );
734
734
if (!element )
735
735
return NULL ;
736
736
@@ -795,7 +795,8 @@ _elementtree_Element___deepcopy___impl(ElementObject *self, PyObject *memo)
795
795
attrib = NULL ;
796
796
}
797
797
798
- element = (ElementObject * ) create_new_element (tag , attrib );
798
+ elementtreestate * st = ET_STATE_GLOBAL ;
799
+ element = (ElementObject * ) create_new_element (st , tag , attrib );
799
800
800
801
Py_DECREF (tag );
801
802
Py_XDECREF (attrib );
@@ -818,7 +819,6 @@ _elementtree_Element___deepcopy___impl(ElementObject *self, PyObject *memo)
818
819
if (element_resize (element , self -> extra -> length ) < 0 )
819
820
goto error ;
820
821
821
- elementtreestate * st = ET_STATE_GLOBAL ;
822
822
for (i = 0 ; i < self -> extra -> length ; i ++ ) {
823
823
PyObject * child = deepcopy (self -> extra -> children [i ], memo );
824
824
if (!child || !Element_Check (st , child )) {
@@ -1550,7 +1550,8 @@ _elementtree_Element_makeelement_impl(ElementObject *self, PyObject *tag,
1550
1550
if (!attrib )
1551
1551
return NULL ;
1552
1552
1553
- elem = create_new_element (tag , attrib );
1553
+ elementtreestate * st = ET_STATE_GLOBAL ;
1554
+ elem = create_new_element (st , tag , attrib );
1554
1555
1555
1556
Py_DECREF (attrib );
1556
1557
@@ -2614,7 +2615,7 @@ treebuilder_handle_start(TreeBuilderObject* self, PyObject* tag,
2614
2615
}
2615
2616
2616
2617
if (!self -> element_factory ) {
2617
- node = create_new_element (tag , attrib );
2618
+ node = create_new_element (st , tag , attrib );
2618
2619
} else if (attrib == NULL ) {
2619
2620
attrib = PyDict_New ();
2620
2621
if (!attrib )
0 commit comments