summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorTim Peters <tim.peters@gmail.com>2003-04-07 17:51:59 (GMT)
committerTim Peters <tim.peters@gmail.com>2003-04-07 17:51:59 (GMT)
commitdf875b99fcb69c18168fb761ddaa722a034175dd (patch)
treee61ba67f62a7bad46095b5a49523edf475950558 /Objects
parentcb8ed53014ea04c2f1f340c720cb670c888df6bb (diff)
downloadcpython-df875b99fcb69c18168fb761ddaa722a034175dd.zip
cpython-df875b99fcb69c18168fb761ddaa722a034175dd.tar.gz
cpython-df875b99fcb69c18168fb761ddaa722a034175dd.tar.bz2
New private API function _PyInstance_Lookup. gc will use this to figure
out whether __del__ exists, without executing any Python-level code.
Diffstat (limited to 'Objects')
-rw-r--r--Objects/classobject.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/Objects/classobject.c b/Objects/classobject.c
index 80aabbf..89a3673 100644
--- a/Objects/classobject.c
+++ b/Objects/classobject.c
@@ -759,6 +759,27 @@ instance_getattr(register PyInstanceObject *inst, PyObject *name)
return res;
}
+/* See classobject.h comments: this only does dict lookups, and is always
+ * safe to call.
+ */
+PyObject *
+_PyInstance_Lookup(PyObject *pinst, PyObject *name)
+{
+ PyObject *v;
+ PyClassObject *class;
+ PyInstanceObject *inst; /* pinst cast to the right type */
+
+ assert(PyInstance_Check(pinst));
+ inst = (PyInstanceObject *)pinst;
+
+ assert(PyString_Check(name));
+
+ v = PyDict_GetItem(inst->in_dict, name);
+ if (v == NULL)
+ v = class_lookup(inst->in_class, name, &class);
+ return v;
+}
+
static int
instance_setattr1(PyInstanceObject *inst, PyObject *name, PyObject *v)
{