diff -r 3f42c9dbd8a7 Modules/_csv.c --- a/Modules/_csv.c Wed Aug 08 20:57:24 2012 -0700 +++ b/Modules/_csv.c Thu Aug 09 18:18:29 2012 +0300 @@ -166,8 +166,12 @@ { if (src == NULL) *target = dflt; - else - *target = PyObject_IsTrue(src); + else { + int b = PyObject_IsTrue(src); + if (b < 0) + return -1; + *target = b; + } return 0; } diff -r 3f42c9dbd8a7 Modules/_io/textio.c --- a/Modules/_io/textio.c Wed Aug 08 20:57:24 2012 -0700 +++ b/Modules/_io/textio.c Thu Aug 09 18:18:29 2012 +0300 @@ -1046,8 +1046,11 @@ res = PyObject_CallMethod(buffer, "seekable", NULL); if (res == NULL) goto error; - self->seekable = self->telling = PyObject_IsTrue(res); + r = PyObject_IsTrue(res); Py_DECREF(res); + if (r < 0) + goto error; + self->seekable = self->telling = r; self->has_read1 = PyObject_HasAttrString(buffer, "read1"); diff -r 3f42c9dbd8a7 Modules/_posixsubprocess.c --- a/Modules/_posixsubprocess.c Wed Aug 08 20:57:24 2012 -0700 +++ b/Modules/_posixsubprocess.c Thu Aug 09 18:18:29 2012 +0300 @@ -525,6 +525,8 @@ return NULL; close_fds = PyObject_IsTrue(py_close_fds); + if (close_fds < 0) + return NULL; if (close_fds && errpipe_write < 3) { /* precondition */ PyErr_SetString(PyExc_ValueError, "errpipe_write must be >= 3"); return NULL; diff -r 3f42c9dbd8a7 Modules/_ssl.c --- a/Modules/_ssl.c Wed Aug 08 20:57:24 2012 -0700 +++ b/Modules/_ssl.c Thu Aug 09 18:18:29 2012 +0300 @@ -883,6 +883,7 @@ int len; int verification; PyObject *binary_mode = Py_None; + int b; if (!PyArg_ParseTuple(args, "|O:peer_certificate", &binary_mode)) return NULL; @@ -890,7 +891,10 @@ if (!self->peer_cert) Py_RETURN_NONE; - if (PyObject_IsTrue(binary_mode)) { + b = PyObject_IsTrue(binary_mode); + if (b < 0) + return NULL; + if (b) { /* return cert in DER-encoded format */ unsigned char *bytes_buf = NULL; diff -r 3f42c9dbd8a7 Modules/itertoolsmodule.c --- a/Modules/itertoolsmodule.c Wed Aug 08 20:57:24 2012 -0700 +++ b/Modules/itertoolsmodule.c Thu Aug 09 18:18:29 2012 +0300 @@ -903,11 +903,13 @@ } ok = PyObject_IsTrue(good); Py_DECREF(good); - if (!ok) { + if (ok == 0) { lz->start = 1; return item; } Py_DECREF(item); + if (ok < 0) + return NULL; } } @@ -1043,10 +1045,11 @@ } ok = PyObject_IsTrue(good); Py_DECREF(good); - if (ok) + if (ok > 0) return item; Py_DECREF(item); - lz->stop = 1; + if (ok == 0) + lz->stop = 1; return NULL; } @@ -2959,9 +2962,11 @@ ok = PyObject_IsTrue(good); Py_DECREF(good); } - if (!ok) + if (ok == 0) return item; Py_DECREF(item); + if (ok < 0) + return NULL; } } diff -r 3f42c9dbd8a7 Modules/parsermodule.c --- a/Modules/parsermodule.c Wed Aug 08 20:57:24 2012 -0700 +++ b/Modules/parsermodule.c Thu Aug 09 18:18:29 2012 +0300 @@ -401,10 +401,14 @@ int lineno = 0; int col_offset = 0; if (line_option != NULL) { - lineno = (PyObject_IsTrue(line_option) != 0) ? 1 : 0; + lineno = PyObject_IsTrue(line_option); + if (lineno < 0) + return NULL; } if (col_option != NULL) { - col_offset = (PyObject_IsTrue(col_option) != 0) ? 1 : 0; + col_offset = PyObject_IsTrue(col_option); + if (col_offset < 0) + return NULL; } /* * Convert ST into a tuple representation. Use Guido's function, @@ -444,10 +448,14 @@ int lineno = 0; int col_offset = 0; if (line_option != 0) { - lineno = PyObject_IsTrue(line_option) ? 1 : 0; + lineno = PyObject_IsTrue(line_option); + if (lineno < 0) + return NULL; } - if (col_option != NULL) { - col_offset = (PyObject_IsTrue(col_option) != 0) ? 1 : 0; + if (col_option != 0) { + col_offset = PyObject_IsTrue(col_option); + if (col_offset < 0) + return NULL; } /* * Convert ST into a tuple representation. Use Guido's function, diff -r 3f42c9dbd8a7 Modules/pyexpat.c --- a/Modules/pyexpat.c Wed Aug 08 20:57:24 2012 -0700 +++ b/Modules/pyexpat.c Thu Aug 09 18:18:29 2012 +0300 @@ -1037,8 +1037,12 @@ enum XML_Error rc; if (!PyArg_UnpackTuple(args, "UseForeignDTD", 0, 1, &flagobj)) return NULL; - if (flagobj != NULL) - flag = PyObject_IsTrue(flagobj) ? XML_TRUE : XML_FALSE; + if (flagobj != NULL) { + int b = PyObject_IsTrue(flagobj); + if (b < 0) + return NULL; + flag = b ? XML_TRUE : XML_FALSE; + } rc = XML_UseForeignDTD(self->itself, flag); if (rc != XML_ERROR_NONE) { return set_error(self, rc); @@ -1397,7 +1401,10 @@ } 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) { @@ -1416,25 +1423,25 @@ 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; } diff -r 3f42c9dbd8a7 Objects/typeobject.c --- a/Objects/typeobject.c Wed Aug 08 20:57:24 2012 -0700 +++ b/Objects/typeobject.c Thu Aug 09 18:18:29 2012 +0300 @@ -353,12 +353,16 @@ } if (res == 0) { PyType_Modified(type); - if (value && PyObject_IsTrue(value)) { - type->tp_flags |= Py_TPFLAGS_IS_ABSTRACT; + if (value) { + int b = PyObject_IsTrue(value); + if (b < 0) + return -1; + if (b) { + type->tp_flags |= Py_TPFLAGS_IS_ABSTRACT; + return res; + } } - else { - type->tp_flags &= ~Py_TPFLAGS_IS_ABSTRACT; - } + type->tp_flags &= ~Py_TPFLAGS_IS_ABSTRACT; } return res; } diff -r 3f42c9dbd8a7 Python/bltinmodule.c --- a/Python/bltinmodule.c Wed Aug 08 20:57:24 2012 -0700 +++ b/Python/bltinmodule.c Thu Aug 09 18:18:29 2012 +0300 @@ -428,9 +428,11 @@ ok = PyObject_IsTrue(good); Py_DECREF(good); } - if (ok) + if (ok > 0) return item; Py_DECREF(item); + if (ok < 0) + return NULL; } } diff -r 3f42c9dbd8a7 Python/import.c --- a/Python/import.c Wed Aug 08 20:57:24 2012 -0700 +++ b/Python/import.c Thu Aug 09 18:18:29 2012 +0300 @@ -1338,7 +1338,10 @@ name, pathname); if (cpathname) { PyObject *ro = PySys_GetObject("dont_write_bytecode"); - if (ro == NULL || !PyObject_IsTrue(ro)) + int b = (ro == NULL) ? 0 : PyObject_IsTrue(ro); + if (b < 0) + goto error_exit; + if (!b) write_compiled_module(co, cpathname, &st); } } @@ -2504,7 +2507,13 @@ } if (fromlist != NULL) { - if (fromlist == Py_None || !PyObject_IsTrue(fromlist)) + int b = (fromlist == Py_None) ? 0 : PyObject_IsTrue(fromlist); + if (b < 0) { + Py_DECREF(tail); + Py_DECREF(head); + goto error_exit; + } + if (!b) fromlist = NULL; }