summaryrefslogtreecommitdiffstats
path: root/Modules/parsermodule.c
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2012-08-15 21:18:25 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2012-08-15 21:18:25 (GMT)
commit6f430e496339aea3e688165340456b555d5e1035 (patch)
tree197393decf924def07e006f3e35cf21f2fec0f08 /Modules/parsermodule.c
parentdd7c55250d67de4d430a0c51dba4f3c0cd8f6ed3 (diff)
downloadcpython-6f430e496339aea3e688165340456b555d5e1035.zip
cpython-6f430e496339aea3e688165340456b555d5e1035.tar.gz
cpython-6f430e496339aea3e688165340456b555d5e1035.tar.bz2
Issue #15604: Update uses of PyObject_IsTrue() to check for and handle errors correctly.
Patch by Serhiy Storchaka.
Diffstat (limited to 'Modules/parsermodule.c')
-rw-r--r--Modules/parsermodule.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/Modules/parsermodule.c b/Modules/parsermodule.c
index 84516ec..b8732dc 100644
--- a/Modules/parsermodule.c
+++ b/Modules/parsermodule.c
@@ -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,