mirror of
https://github.com/python/cpython.git
synced 2025-08-30 21:48:47 +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
dd7c55250d
commit
6f430e4963
11 changed files with 87 additions and 39 deletions
|
@ -428,9 +428,11 @@ filter_next(filterobject *lz)
|
|||
ok = PyObject_IsTrue(good);
|
||||
Py_DECREF(good);
|
||||
}
|
||||
if (ok)
|
||||
if (ok > 0)
|
||||
return item;
|
||||
Py_DECREF(item);
|
||||
if (ok < 0)
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1338,7 +1338,10 @@ load_source_module(char *name, char *pathname, FILE *fp)
|
|||
name, pathname);
|
||||
if (cpathname) {
|
||||
PyObject *ro = PySys_GetObject("dont_write_bytecode");
|
||||
if (ro == NULL || !PyObject_IsTrue(ro))
|
||||
int b = (ro == NULL) ? 0 : PyObject_IsTrue(ro);
|
||||
if (b < 0)
|
||||
goto error_exit;
|
||||
if (!b)
|
||||
write_compiled_module(co, cpathname, &st);
|
||||
}
|
||||
}
|
||||
|
@ -2504,7 +2507,13 @@ import_module_level(char *name, PyObject *globals, PyObject *locals,
|
|||
}
|
||||
|
||||
if (fromlist != NULL) {
|
||||
if (fromlist == Py_None || !PyObject_IsTrue(fromlist))
|
||||
int b = (fromlist == Py_None) ? 0 : PyObject_IsTrue(fromlist);
|
||||
if (b < 0) {
|
||||
Py_DECREF(tail);
|
||||
Py_DECREF(head);
|
||||
goto error_exit;
|
||||
}
|
||||
if (!b)
|
||||
fromlist = NULL;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue