@@ -965,9 +965,8 @@ element_setstate_from_attributes(ElementObject *self,
965965 return NULL ;
966966 }
967967
968- Py_CLEAR (self -> tag );
969- self -> tag = tag ;
970- Py_INCREF (self -> tag );
968+ Py_INCREF (tag );
969+ Py_SETREF (self -> tag , tag );
971970
972971 _clear_joined_ptr (& self -> text );
973972 self -> text = text ? JOIN_SET (text , PyList_CheckExact (text )) : Py_None ;
@@ -1010,9 +1009,8 @@ element_setstate_from_attributes(ElementObject *self,
10101009
10111010 /* Stash attrib. */
10121011 if (attrib ) {
1013- Py_CLEAR (self -> extra -> attrib );
1014- self -> extra -> attrib = attrib ;
10151012 Py_INCREF (attrib );
1013+ Py_SETREF (self -> extra -> attrib , attrib );
10161014 }
10171015
10181016 Py_RETURN_NONE ;
@@ -1961,8 +1959,7 @@ element_tag_setter(ElementObject *self, PyObject *value, void *closure)
19611959{
19621960 _VALIDATE_ATTR_VALUE (value );
19631961 Py_INCREF (value );
1964- Py_DECREF (self -> tag );
1965- self -> tag = value ;
1962+ Py_SETREF (self -> tag , value );
19661963 return 0 ;
19671964}
19681965
@@ -1995,8 +1992,7 @@ element_attrib_setter(ElementObject *self, PyObject *value, void *closure)
19951992 return -1 ;
19961993 }
19971994 Py_INCREF (value );
1998- Py_DECREF (self -> extra -> attrib );
1999- self -> extra -> attrib = value ;
1995+ Py_SETREF (self -> extra -> attrib , value );
20001996 return 0 ;
20011997}
20021998
@@ -2533,13 +2529,10 @@ treebuilder_handle_start(TreeBuilderObject* self, PyObject* tag,
25332529 }
25342530 self -> index ++ ;
25352531
2536- Py_DECREF (this );
25372532 Py_INCREF (node );
2538- self -> this = node ;
2539-
2540- Py_DECREF (self -> last );
2533+ Py_SETREF (self -> this , node );
25412534 Py_INCREF (node );
2542- self -> last = node ;
2535+ Py_SETREF ( self -> last , node ) ;
25432536
25442537 if (treebuilder_append_event (self , self -> start_event_obj , node ) < 0 )
25452538 goto error ;
@@ -2612,15 +2605,12 @@ treebuilder_handle_end(TreeBuilderObject* self, PyObject* tag)
26122605 return NULL ;
26132606 }
26142607
2615- self -> index -- ;
2616-
2617- item = PyList_GET_ITEM (self -> stack , self -> index );
2618- Py_INCREF (item );
2619-
2620- Py_DECREF (self -> last );
2621-
2608+ item = self -> last ;
26222609 self -> last = self -> this ;
2623- self -> this = item ;
2610+ self -> index -- ;
2611+ self -> this = PyList_GET_ITEM (self -> stack , self -> index );
2612+ Py_INCREF (self -> this );
2613+ Py_DECREF (item );
26242614
26252615 if (treebuilder_append_event (self , self -> end_event_obj , self -> last ) < 0 )
26262616 return NULL ;
0 commit comments