summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2023-12-14 12:24:24 (GMT)
committerGitHub <noreply@github.com>2023-12-14 12:24:24 (GMT)
commit1161c14e8c68296fc465cd48970b32be9bee012e (patch)
tree369e0252cf2cb96bedefb0c891b7fbe3b0120152 /Python
parent12f0bbd6e08bcc1e7165f2641716f7685c1db35c (diff)
downloadcpython-1161c14e8c68296fc465cd48970b32be9bee012e.zip
cpython-1161c14e8c68296fc465cd48970b32be9bee012e.tar.gz
cpython-1161c14e8c68296fc465cd48970b32be9bee012e.tar.bz2
gh-112716: Fix SystemError when __builtins__ is not a dict (GH-112770)
It was raised in two cases: * in the import statement when looking up __import__ * in pickling some builtin type when looking up built-ins iter, getattr, etc.
Diffstat (limited to 'Python')
-rw-r--r--Python/ceval.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/Python/ceval.c b/Python/ceval.c
index d92ab92..8e0be70 100644
--- a/Python/ceval.c
+++ b/Python/ceval.c
@@ -2417,7 +2417,7 @@ PyObject *
_PyEval_GetBuiltin(PyObject *name)
{
PyObject *attr;
- if (PyDict_GetItemRef(PyEval_GetBuiltins(), name, &attr) == 0) {
+ if (PyMapping_GetOptionalItem(PyEval_GetBuiltins(), name, &attr) == 0) {
PyErr_SetObject(PyExc_AttributeError, name);
}
return attr;
@@ -2570,7 +2570,7 @@ import_name(PyThreadState *tstate, _PyInterpreterFrame *frame,
PyObject *name, PyObject *fromlist, PyObject *level)
{
PyObject *import_func;
- if (PyDict_GetItemRef(frame->f_builtins, &_Py_ID(__import__), &import_func) < 0) {
+ if (PyMapping_GetOptionalItem(frame->f_builtins, &_Py_ID(__import__), &import_func) < 0) {
return NULL;
}
if (import_func == NULL) {