New private API function _PyInstance_Lookup. gc will use this to figure

out whether __del__ exists, without executing any Python-level code.
This commit is contained in:
Tim Peters 2003-04-07 17:51:59 +00:00
parent cb8ed53014
commit df875b99fc
2 changed files with 33 additions and 0 deletions

View file

@ -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)
{