Mercurial > cpython-lru_cache-weakref
diff Modules/parsermodule.c @ 78604:56dc7b09f390 3.2
Issue #15604: Update uses of PyObject_IsTrue() to check for and handle errors correctly.
Patch by Serhiy Storchaka.
| author | Antoine Pitrou <solipsis@pitrou.net> |
|---|---|
| date | Wed, 15 Aug 2012 23:18:25 +0200 |
| parents | 91884d04de06 |
| children | fdf907708f49 b878df1d23b1 |
line wrap: on
line diff
--- a/Modules/parsermodule.c Wed Aug 15 21:37:35 2012 +0200 +++ b/Modules/parsermodule.c Wed Aug 15 23:18:25 2012 +0200 @@ -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,
