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:18:25 +02:00
parent dd7c55250d
commit 6f430e4963
11 changed files with 87 additions and 39 deletions

View file

@ -401,10 +401,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,
@ -444,10 +448,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,