[Python-checkins] cpython: frameobject.c: Use an identifer instead of creating explicitly an interned
victor.stinner
python-checkins at python.org
Thu Nov 7 22:39:34 CET 2013
http://hg.python.org/cpython/rev/23f0529a8b2f
changeset: 86998:23f0529a8b2f
user: Victor Stinner <victor.stinner at gmail.com>
date: Thu Nov 07 22:22:39 2013 +0100
summary:
frameobject.c: Use an identifer instead of creating explicitly an interned
string for "__builtins__" literal string
files:
Objects/frameobject.c | 12 +++++-------
1 files changed, 5 insertions(+), 7 deletions(-)
diff --git a/Objects/frameobject.c b/Objects/frameobject.c
--- a/Objects/frameobject.c
+++ b/Objects/frameobject.c
@@ -601,13 +601,13 @@
0, /* tp_dict */
};
-static PyObject *builtin_object;
+_Py_IDENTIFIER(__builtins__);
int _PyFrame_Init()
{
- builtin_object = PyUnicode_InternFromString("__builtins__");
- if (builtin_object == NULL)
- return 0;
+ /* Before, PyId___builtins__ was a string created explicitly in
+ this function. Now there is nothing to initialize anymore, but
+ the function is kept for backward compatibility. */
return 1;
}
@@ -628,7 +628,7 @@
}
#endif
if (back == NULL || back->f_globals != globals) {
- builtins = PyDict_GetItem(globals, builtin_object);
+ builtins = _PyDict_GetItemId(globals, &PyId___builtins__);
if (builtins) {
if (PyModule_Check(builtins)) {
builtins = PyModule_GetDict(builtins);
@@ -994,8 +994,6 @@
PyFrame_Fini(void)
{
(void)PyFrame_ClearFreeList();
- Py_XDECREF(builtin_object);
- builtin_object = NULL;
}
/* Print summary info about the state of the optimized allocator */
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list