mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-05-22 21:32:31 +00:00
Add error checks to Python objectifier (#281)
PYOBJ.COM was failing when statically analyzing _pyio.py in MODE=dbg because co_consts contained a big number, which dirtied the interpreter exception state. We now do comprehensive error checking w/ Python API. The -DSTACK_FRAME_UNLIMITED CPPFLAG has been removed from DES since its self test function has been fixed to use heap memory rather than making aggressive use of the stack. This change also fixes a regression with function tracing (the --ftrace flag a.k.a. ftrace_install() a.k.a. cosmo.ftrace) in ASAN build modes. Lastly, the _tracemalloc module should now always be available for use in MODE=dbg.
This commit is contained in:
parent
57f0eed382
commit
9cb54218ab
10 changed files with 323 additions and 422 deletions
13
third_party/python/Objects/tupleobject.c
vendored
13
third_party/python/Objects/tupleobject.c
vendored
|
@ -159,18 +159,23 @@ PyTuple_Size(PyObject *op)
|
|||
return Py_SIZE(op);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns object at position 𝑖 in the tuple pointed to by 𝑝.
|
||||
*
|
||||
* @return borrowed reference, or NULL if 𝑖 is out of bounds
|
||||
*/
|
||||
PyObject *
|
||||
PyTuple_GetItem(PyObject *op, Py_ssize_t i)
|
||||
PyTuple_GetItem(PyObject *p, Py_ssize_t i)
|
||||
{
|
||||
if (!PyTuple_Check(op)) {
|
||||
if (!PyTuple_Check(p)) {
|
||||
PyErr_BadInternalCall();
|
||||
return NULL;
|
||||
}
|
||||
if (i < 0 || i >= Py_SIZE(op)) {
|
||||
if (i < 0 || i >= Py_SIZE(p)) {
|
||||
PyErr_SetString(PyExc_IndexError, "tuple index out of range");
|
||||
return NULL;
|
||||
}
|
||||
return ((PyTupleObject *)op) -> ob_item[i];
|
||||
return ((PyTupleObject *)p) -> ob_item[i];
|
||||
}
|
||||
|
||||
int
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue