mirror of
https://github.com/python/cpython.git
synced 2025-12-15 21:44:50 +00:00
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:
parent
cb8ed53014
commit
df875b99fc
2 changed files with 33 additions and 0 deletions
|
|
@ -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)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue