Issue #15604: Update uses of PyObject_IsTrue() to check for and handle errors correctly.

Patch by Serhiy Storchaka.
This commit is contained in:
Antoine Pitrou 2012-08-15 23:16:51 +02:00
parent 4ffe9a0640
commit c5bef75c77
11 changed files with 112 additions and 52 deletions

View file

@ -350,10 +350,14 @@ parser_st2tuple(PyST_Object *self, PyObject *args, PyObject *kw)
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,
@ -401,10 +405,14 @@ parser_st2list(PyST_Object *self, PyObject *args, PyObject *kw)
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,