[Python-checkins] CVS: python/dist/src/Python sysmodule.c,2.64,2.65

Mark Hammond python-dev@python.org
Tue, 20 Jun 2000 01:12:50 -0700


Update of /cvsroot/python/python/dist/src/Python
In directory slayer.i.sourceforge.net:/tmp/cvs-serv7059

Modified Files:
	sysmodule.c 
Log Message:
Added a new debug method sys.gettotalrefcount(), which returns the total number of references on all Python objects.  This is only enabled when Py_TRACE_REFS is defined (which includes default debug builds under Windows).

Also removed a redundant cast from sys.getrefcount(), as discussed on the patches list.

Index: sysmodule.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/sysmodule.c,v
retrieving revision 2.64
retrieving revision 2.65
diff -C2 -r2.64 -r2.65
*** sysmodule.c	2000/06/07 09:13:41	2.64
--- sysmodule.c	2000/06/20 08:12:48	2.65
***************
*** 266,272 ****
  	if (!PyArg_ParseTuple(args, "O:getrefcount", &arg))
  		return NULL;
! 	return PyInt_FromLong((long) arg->ob_refcnt);
  }
  
  static char getrefcount_doc[] =
  "getrefcount(object) -> integer\n\
--- 266,284 ----
  	if (!PyArg_ParseTuple(args, "O:getrefcount", &arg))
  		return NULL;
! 	return PyInt_FromLong(arg->ob_refcnt);
  }
  
+ #ifdef Py_TRACE_REFS
+ static PyObject *
+ sys_gettotalrefcount(PyObject *self, PyObject *args)
+ {
+ 	extern long _Py_RefTotal;
+ 	if (!PyArg_ParseTuple(args, ":gettotalrefcount"))
+ 		return NULL;
+ 	return PyInt_FromLong(_Py_RefTotal);
+ }
+ 
+ #endif /* Py_TRACE_REFS */
+ 
  static char getrefcount_doc[] =
  "getrefcount(object) -> integer\n\
***************
*** 311,314 ****
--- 323,327 ----
  #ifdef Py_TRACE_REFS
  	{"getobjects",	_Py_GetObjects, 1},
+ 	{"gettotalrefcount", sys_gettotalrefcount, 1},
  #endif
  	{"getrefcount",	sys_getrefcount, 1, getrefcount_doc},