Skip to content

Commit d3a8365

Browse files
Always set __builtins__ in _PyFunction_FromXIData().
1 parent 96905bd commit d3a8365

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

Python/crossinterp_data_lookup.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -701,6 +701,13 @@ _PyFunction_FromXIData(_PyXIData_t *xidata)
701701
Py_DECREF(code);
702702
return NULL;
703703
}
704+
PyThreadState *tstate = _PyThreadState_GET();
705+
if (PyDict_SetItemString(globals, "__builtins__",
706+
tstate->interp->builtins) < 0)
707+
{
708+
Py_DECREF(globals);
709+
return NULL;
710+
}
704711
PyObject *func = PyFunction_New(code, globals);
705712
Py_DECREF(code);
706713
Py_DECREF(globals);

0 commit comments

Comments
 (0)