diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2020-10-26 06:43:39 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-26 06:43:39 (GMT) |
commit | fb5db7ec58624cab0797b4050735be865d380823 (patch) | |
tree | 7b0421bb759ba01f0d735296738472faa4ce11b8 /Python/ceval.c | |
parent | 96a9eed2457c05af6953890d89463704c9d99c57 (diff) | |
download | cpython-fb5db7ec58624cab0797b4050735be865d380823.zip cpython-fb5db7ec58624cab0797b4050735be865d380823.tar.gz cpython-fb5db7ec58624cab0797b4050735be865d380823.tar.bz2 |
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.
Diffstat (limited to 'Python/ceval.c')
-rw-r--r-- | Python/ceval.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/Python/ceval.c b/Python/ceval.c index fafbf75..7338be5 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -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, |