mirror of
https://github.com/python/cpython.git
synced 2025-08-31 05:58:33 +00:00
bpo-42006: Stop using PyDict_GetItem, PyDict_GetItemString and _PyDict_GetItemId. (GH-22648)
These functions are considered not safe because they suppress all internal errors and can return wrong result. PyDict_GetItemString and _PyDict_GetItemId can also silence current exception in rare cases. Remove no longer used _PyDict_GetItemId. Add _PyDict_ContainsId and rename _PyDict_Contains into _PyDict_Contains_KnownHash.
This commit is contained in:
parent
96a9eed245
commit
fb5db7ec58
17 changed files with 259 additions and 142 deletions
|
@ -1446,11 +1446,18 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag)
|
|||
}
|
||||
|
||||
#ifdef LLTRACE
|
||||
lltrace = _PyDict_GetItemId(f->f_globals, &PyId___ltrace__) != NULL;
|
||||
{
|
||||
int r = _PyDict_ContainsId(f->f_globals, &PyId___ltrace__);
|
||||
if (r < 0) {
|
||||
goto exit_eval_frame;
|
||||
}
|
||||
lltrace = r;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (throwflag) /* support for generator.throw() */
|
||||
if (throwflag) { /* support for generator.throw() */
|
||||
goto error;
|
||||
}
|
||||
|
||||
#ifdef Py_DEBUG
|
||||
/* _PyEval_EvalFrameDefault() must not be called with an exception set,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue