@@ -1033,13 +1033,16 @@ static PyObject *
10331033xmlparse_UseForeignDTD (xmlparseobject * self , PyObject * args )
10341034{
10351035 PyObject * flagobj = NULL ;
1036- XML_Bool flag = XML_TRUE ;
1036+ int flag = 1 ;
10371037 enum XML_Error rc ;
1038- if (!PyArg_UnpackTuple (args , "UseForeignDTD" , 0 , 1 , & flagobj ))
1038+ if (!PyArg_ParseTuple (args , "O: UseForeignDTD" , & flagobj ))
10391039 return NULL ;
1040- if (flagobj != NULL )
1041- flag = PyObject_IsTrue (flagobj ) ? XML_TRUE : XML_FALSE ;
1042- rc = XML_UseForeignDTD (self -> itself , flag );
1040+ if (flagobj != NULL ) {
1041+ flag = PyObject_IsTrue (flagobj );
1042+ if (flag < 0 )
1043+ return NULL ;
1044+ }
1045+ rc = XML_UseForeignDTD (self -> itself , flag ? XML_TRUE : XML_FALSE );
10431046 if (rc != XML_ERROR_NONE ) {
10441047 return set_error (self , rc );
10451048 }
@@ -1397,7 +1400,10 @@ xmlparse_setattro(xmlparseobject *self, PyObject *name, PyObject *v)
13971400 }
13981401 assert (PyUnicode_Check (name ));
13991402 if (PyUnicode_CompareWithASCIIString (name , "buffer_text" ) == 0 ) {
1400- if (PyObject_IsTrue (v )) {
1403+ int b = PyObject_IsTrue (v );
1404+ if (b < 0 )
1405+ return -1 ;
1406+ if (b ) {
14011407 if (self -> buffer == NULL ) {
14021408 self -> buffer = malloc (self -> buffer_size );
14031409 if (self -> buffer == NULL ) {
@@ -1416,25 +1422,25 @@ xmlparse_setattro(xmlparseobject *self, PyObject *name, PyObject *v)
14161422 return 0 ;
14171423 }
14181424 if (PyUnicode_CompareWithASCIIString (name , "namespace_prefixes" ) == 0 ) {
1419- if ( PyObject_IsTrue (v ))
1420- self -> ns_prefixes = 1 ;
1421- else
1422- self -> ns_prefixes = 0 ;
1425+ int b = PyObject_IsTrue (v );
1426+ if ( b < 0 )
1427+ return -1 ;
1428+ self -> ns_prefixes = b ;
14231429 XML_SetReturnNSTriplet (self -> itself , self -> ns_prefixes );
14241430 return 0 ;
14251431 }
14261432 if (PyUnicode_CompareWithASCIIString (name , "ordered_attributes" ) == 0 ) {
1427- if ( PyObject_IsTrue (v ))
1428- self -> ordered_attributes = 1 ;
1429- else
1430- self -> ordered_attributes = 0 ;
1433+ int b = PyObject_IsTrue (v );
1434+ if ( b < 0 )
1435+ return -1 ;
1436+ self -> ordered_attributes = b ;
14311437 return 0 ;
14321438 }
14331439 if (PyUnicode_CompareWithASCIIString (name , "specified_attributes" ) == 0 ) {
1434- if ( PyObject_IsTrue (v ))
1435- self -> specified_attributes = 1 ;
1436- else
1437- self -> specified_attributes = 0 ;
1440+ int b = PyObject_IsTrue (v );
1441+ if ( b < 0 )
1442+ return -1 ;
1443+ self -> specified_attributes = b ;
14381444 return 0 ;
14391445 }
14401446
0 commit comments