Commit 07e9e380 authored by Victor Stinner's avatar Victor Stinner

frameobject.c: Use an identifer instead of creating explicitly an interned

string for "__builtins__" literal string
parent e8453bc1
...@@ -601,13 +601,13 @@ PyTypeObject PyFrame_Type = { ...@@ -601,13 +601,13 @@ PyTypeObject PyFrame_Type = {
0, /* tp_dict */ 0, /* tp_dict */
}; };
static PyObject *builtin_object; _Py_IDENTIFIER(__builtins__);
int _PyFrame_Init() int _PyFrame_Init()
{ {
builtin_object = PyUnicode_InternFromString("__builtins__"); /* Before, PyId___builtins__ was a string created explicitly in
if (builtin_object == NULL) this function. Now there is nothing to initialize anymore, but
return 0; the function is kept for backward compatibility. */
return 1; return 1;
} }
...@@ -628,7 +628,7 @@ PyFrame_New(PyThreadState *tstate, PyCodeObject *code, PyObject *globals, ...@@ -628,7 +628,7 @@ PyFrame_New(PyThreadState *tstate, PyCodeObject *code, PyObject *globals,
} }
#endif #endif
if (back == NULL || back->f_globals != globals) { if (back == NULL || back->f_globals != globals) {
builtins = PyDict_GetItem(globals, builtin_object); builtins = _PyDict_GetItemId(globals, &PyId___builtins__);
if (builtins) { if (builtins) {
if (PyModule_Check(builtins)) { if (PyModule_Check(builtins)) {
builtins = PyModule_GetDict(builtins); builtins = PyModule_GetDict(builtins);
...@@ -994,8 +994,6 @@ void ...@@ -994,8 +994,6 @@ void
PyFrame_Fini(void) PyFrame_Fini(void)
{ {
(void)PyFrame_ClearFreeList(); (void)PyFrame_ClearFreeList();
Py_XDECREF(builtin_object);
builtin_object = NULL;
} }
/* Print summary info about the state of the optimized allocator */ /* Print summary info about the state of the optimized allocator */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment