summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorMartin v. Löwis <martin@v.loewis.de>2004-03-23 18:40:15 (GMT)
committerMartin v. Löwis <martin@v.loewis.de>2004-03-23 18:40:15 (GMT)
commit321c9ab74c5ae88cd87c0c8263f323a90c28d772 (patch)
tree70e5cef99fd75f57d20d13b0922d257c22ee3c77 /Objects
parent83969eeeeb08fa27d8564303792107750ff09598 (diff)
downloadcpython-321c9ab74c5ae88cd87c0c8263f323a90c28d772.zip
cpython-321c9ab74c5ae88cd87c0c8263f323a90c28d772.tar.gz
cpython-321c9ab74c5ae88cd87c0c8263f323a90c28d772.tar.bz2
Intern __name__.
Diffstat (limited to 'Objects')
-rw-r--r--Objects/funcobject.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/Objects/funcobject.c b/Objects/funcobject.c
index c414bca..76acf98 100644
--- a/Objects/funcobject.c
+++ b/Objects/funcobject.c
@@ -11,6 +11,7 @@ PyFunction_New(PyObject *code, PyObject *globals)
{
PyFunctionObject *op = PyObject_GC_New(PyFunctionObject,
&PyFunction_Type);
+ static PyObject *__name__ = 0;
if (op != NULL) {
PyObject *doc;
PyObject *consts;
@@ -40,7 +41,14 @@ PyFunction_New(PyObject *code, PyObject *globals)
/* __module__: If module name is in globals, use it.
Otherwise, use None.
*/
- module = PyDict_GetItemString(globals, "__name__");
+ if (!__name__) {
+ __name__ = PyString_InternFromString("__name__");
+ if (!__name__) {
+ Py_DECREF(op);
+ return NULL;
+ }
+ }
+ module = PyDict_GetItem(globals, __name__);
if (module) {
Py_INCREF(module);
op->func_module = module;