[Python-checkins] python/dist/src/Objects classobject.c,2.168,2.169

tim_one@users.sourceforge.net tim_one@users.sourceforge.net
Mon, 07 Apr 2003 10:52:03 -0700


Update of /cvsroot/python/python/dist/src/Objects
In directory sc8-pr-cvs1:/tmp/cvs-serv9658/Objects

Modified Files:
	classobject.c 
Log Message:
New private API function _PyInstance_Lookup.  gc will use this to figure
out whether __del__ exists, without executing any Python-level code.


Index: classobject.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/classobject.c,v
retrieving revision 2.168
retrieving revision 2.169
diff -C2 -d -r2.168 -r2.169
*** classobject.c	11 Feb 2003 18:43:00 -0000	2.168
--- classobject.c	7 Apr 2003 17:51:59 -0000	2.169
***************
*** 760,763 ****
--- 760,784 ----
  }
  
+ /* 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)