summaryrefslogtreecommitdiffstats
path: root/Modules/pyexpat.c
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2012-08-15 21:20:39 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2012-08-15 21:20:39 (GMT)
commit721738fbee8d75dab5a5d3c4f3dbd7c72d76925e (patch)
treec0e693ed7f2e6c44d48555f3cc4d8775ac8e14bb /Modules/pyexpat.c
parent9351117139363f3e600c541bc88139702a055db8 (diff)
parent6f430e496339aea3e688165340456b555d5e1035 (diff)
downloadcpython-721738fbee8d75dab5a5d3c4f3dbd7c72d76925e.zip
cpython-721738fbee8d75dab5a5d3c4f3dbd7c72d76925e.tar.gz
cpython-721738fbee8d75dab5a5d3c4f3dbd7c72d76925e.tar.bz2
Issue #15604: Update uses of PyObject_IsTrue() to check for and handle errors correctly.
Patch by Serhiy Storchaka.
Diffstat (limited to 'Modules/pyexpat.c')
-rw-r--r--Modules/pyexpat.c38
1 files changed, 19 insertions, 19 deletions
diff --git a/Modules/pyexpat.c b/Modules/pyexpat.c
index a500a1e..bd27268 100644
--- a/Modules/pyexpat.c
+++ b/Modules/pyexpat.c
@@ -1033,14 +1033,11 @@ getting the advantage of providing document type information to the parser.\n\
static PyObject *
xmlparse_UseForeignDTD(xmlparseobject *self, PyObject *args)
{
- PyObject *flagobj = NULL;
- XML_Bool flag = XML_TRUE;
+ int flag = 1;
enum XML_Error rc;
- if (!PyArg_UnpackTuple(args, "UseForeignDTD", 0, 1, &flagobj))
+ if (!PyArg_ParseTuple(args, "p:UseForeignDTD", &flag))
return NULL;
- if (flagobj != NULL)
- flag = PyObject_IsTrue(flagobj) ? XML_TRUE : XML_FALSE;
- rc = XML_UseForeignDTD(self->itself, flag);
+ rc = XML_UseForeignDTD(self->itself, flag ? XML_TRUE : XML_FALSE);
if (rc != XML_ERROR_NONE) {
return set_error(self, rc);
}
@@ -1405,7 +1402,10 @@ xmlparse_setattro(xmlparseobject *self, PyObject *name, PyObject *v)
}
assert(PyUnicode_Check(name));
if (PyUnicode_CompareWithASCIIString(name, "buffer_text") == 0) {
- if (PyObject_IsTrue(v)) {
+ int b = PyObject_IsTrue(v);
+ if (b < 0)
+ return -1;
+ if (b) {
if (self->buffer == NULL) {
self->buffer = malloc(self->buffer_size);
if (self->buffer == NULL) {
@@ -1424,25 +1424,25 @@ xmlparse_setattro(xmlparseobject *self, PyObject *name, PyObject *v)
return 0;
}
if (PyUnicode_CompareWithASCIIString(name, "namespace_prefixes") == 0) {
- if (PyObject_IsTrue(v))
- self->ns_prefixes = 1;
- else
- self->ns_prefixes = 0;
+ int b = PyObject_IsTrue(v);
+ if (b < 0)
+ return -1;
+ self->ns_prefixes = b;
XML_SetReturnNSTriplet(self->itself, self->ns_prefixes);
return 0;
}
if (PyUnicode_CompareWithASCIIString(name, "ordered_attributes") == 0) {
- if (PyObject_IsTrue(v))
- self->ordered_attributes = 1;
- else
- self->ordered_attributes = 0;
+ int b = PyObject_IsTrue(v);
+ if (b < 0)
+ return -1;
+ self->ordered_attributes = b;
return 0;
}
if (PyUnicode_CompareWithASCIIString(name, "specified_attributes") == 0) {
- if (PyObject_IsTrue(v))
- self->specified_attributes = 1;
- else
- self->specified_attributes = 0;
+ int b = PyObject_IsTrue(v);
+ if (b < 0)
+ return -1;
+ self->specified_attributes = b;
return 0;
}