@@ -1226,12 +1226,8 @@ xmlparse_dealloc(xmlparseobject *self)
12261226 self -> itself = NULL ;
12271227
12281228 if (self -> handlers != NULL ) {
1229- PyObject * temp ;
1230- for (i = 0 ; handler_info [i ].name != NULL ; i ++ ) {
1231- temp = self -> handlers [i ];
1232- self -> handlers [i ] = NULL ;
1233- Py_XDECREF (temp );
1234- }
1229+ for (i = 0 ; handler_info [i ].name != NULL ; i ++ )
1230+ Py_CLEAR (self -> handlers [i ]);
12351231 PyMem_Free (self -> handlers );
12361232 self -> handlers = NULL ;
12371233 }
@@ -1345,7 +1341,6 @@ sethandler(xmlparseobject *self, PyObject *name, PyObject* v)
13451341 int handlernum = handlername2int (name );
13461342 if (handlernum >= 0 ) {
13471343 xmlhandler c_handler = NULL ;
1348- PyObject * temp = self -> handlers [handlernum ];
13491344
13501345 if (v == Py_None ) {
13511346 /* If this is the character data handler, and a character
@@ -1367,8 +1362,7 @@ sethandler(xmlparseobject *self, PyObject *name, PyObject* v)
13671362 Py_INCREF (v );
13681363 c_handler = handler_info [handlernum ].handler ;
13691364 }
1370- self -> handlers [handlernum ] = v ;
1371- Py_XDECREF (temp );
1365+ Py_SETREF (self -> handlers [handlernum ], v );
13721366 handler_info [handlernum ].setter (self -> itself , c_handler );
13731367 return 1 ;
13741368 }
@@ -1898,15 +1892,12 @@ static void
18981892clear_handlers (xmlparseobject * self , int initial )
18991893{
19001894 int i = 0 ;
1901- PyObject * temp ;
19021895
19031896 for (; handler_info [i ].name != NULL ; i ++ ) {
19041897 if (initial )
19051898 self -> handlers [i ] = NULL ;
19061899 else {
1907- temp = self -> handlers [i ];
1908- self -> handlers [i ] = NULL ;
1909- Py_XDECREF (temp );
1900+ Py_CLEAR (self -> handlers [i ]);
19101901 handler_info [i ].setter (self -> itself , NULL );
19111902 }
19121903 }
0 commit comments