File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -859,8 +859,10 @@ element_getstate(ElementObject *self)
859859 PICKLED_ATTRIB , self -> extra -> attrib ,
860860 PICKLED_TEXT , self -> text ,
861861 PICKLED_TAIL , self -> tail );
862- if (instancedict )
862+ if (instancedict ) {
863+ Py_DECREF (children );
863864 return instancedict ;
865+ }
864866 else {
865867 for (i = 0 ; i < PyList_GET_SIZE (children ); i ++ )
866868 Py_DECREF (PyList_GET_ITEM (children , i ));
@@ -884,25 +886,17 @@ element_setstate_from_attributes(ElementObject *self,
884886 PyErr_SetString (PyExc_TypeError , "tag may not be NULL" );
885887 return NULL ;
886888 }
887- if (!text ) {
888- Py_INCREF (Py_None );
889- text = Py_None ;
890- }
891- if (!tail ) {
892- Py_INCREF (Py_None );
893- tail = Py_None ;
894- }
895889
896890 Py_CLEAR (self -> tag );
897891 self -> tag = tag ;
898892 Py_INCREF (self -> tag );
899893
900894 Py_CLEAR (self -> text );
901- self -> text = text ;
895+ self -> text = text ? text : Py_None ;
902896 Py_INCREF (self -> text );
903897
904898 Py_CLEAR (self -> tail );
905- self -> tail = tail ;
899+ self -> tail = tail ? tail : Py_None ;
906900 Py_INCREF (self -> tail );
907901
908902 /* Handle ATTRIB and CHILDREN. */
You can’t perform that action at this time.
0 commit comments