mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
Issue #15604: Update uses of PyObject_IsTrue() to check for and handle errors correctly.
Patch by Serhiy Storchaka.
This commit is contained in:
parent
4ffe9a0640
commit
c5bef75c77
11 changed files with 112 additions and 52 deletions
|
@ -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,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue