[Python-checkins] python/dist/src/Objects funcobject.c,2.50.4.1,2.50.4.2

jhylton@users.sourceforge.net jhylton@users.sourceforge.net
Fri, 09 May 2003 11:29:23 -0700


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

Modified Files:
      Tag: release22-maint
	funcobject.c 
Log Message:
Backport fixes to make more types collectable.
classmethod, staticmethod, cPickle.Pickler, cPickle.UNpickler


Index: funcobject.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/funcobject.c,v
retrieving revision 2.50.4.1
retrieving revision 2.50.4.2
diff -C2 -d -r2.50.4.1 -r2.50.4.2
*** funcobject.c	18 Mar 2002 03:05:35 -0000	2.50.4.1
--- funcobject.c	9 May 2003 18:29:21 -0000	2.50.4.2
***************
*** 461,468 ****
--- 461,486 ----
  cm_dealloc(classmethod *cm)
  {
+ 	_PyObject_GC_UNTRACK((PyObject *)cm);
  	Py_XDECREF(cm->cm_callable);
  	cm->ob_type->tp_free((PyObject *)cm);
  }
  
+ static int
+ cm_traverse(classmethod *cm, visitproc visit, void *arg)
+ {
+ 	if (!cm->cm_callable)
+ 		return 0;
+ 	return visit(cm->cm_callable, arg);
+ }
+ 
+ static int
+ cm_clear(classmethod *cm)
+ {
+ 	Py_XDECREF(cm->cm_callable);
+ 	cm->cm_callable = NULL;
+ 
+ 	return 0;
+ }
+ 
  static PyObject *
  cm_descr_get(PyObject *self, PyObject *obj, PyObject *type)
***************
*** 536,543 ****
  	0,					/* tp_setattro */
  	0,					/* tp_as_buffer */
! 	Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
  	classmethod_doc,			/* tp_doc */
! 	0,					/* tp_traverse */
! 	0,					/* tp_clear */
  	0,					/* tp_richcompare */
  	0,					/* tp_weaklistoffset */
--- 554,561 ----
  	0,					/* tp_setattro */
  	0,					/* tp_as_buffer */
! 	Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC,
  	classmethod_doc,			/* tp_doc */
! 	(traverseproc)cm_traverse,		/* tp_traverse */
! 	(inquiry)cm_clear,			/* tp_clear */
  	0,					/* tp_richcompare */
  	0,					/* tp_weaklistoffset */
***************
*** 555,559 ****
  	PyType_GenericAlloc,			/* tp_alloc */
  	PyType_GenericNew,			/* tp_new */
! 	_PyObject_Del,				/* tp_free */
  };
  
--- 573,577 ----
  	PyType_GenericAlloc,			/* tp_alloc */
  	PyType_GenericNew,			/* tp_new */
! 	_PyObject_GC_Del,			/* tp_free */
  };
  
***************
*** 595,602 ****
--- 613,638 ----
  sm_dealloc(staticmethod *sm)
  {
+ 	_PyObject_GC_UNTRACK((PyObject *)sm);
  	Py_XDECREF(sm->sm_callable);
  	sm->ob_type->tp_free((PyObject *)sm);
  }
  
+ static int
+ sm_traverse(staticmethod *sm, visitproc visit, void *arg)
+ {
+ 	if (!sm->sm_callable)
+ 		return 0;
+ 	return visit(sm->sm_callable, arg);
+ }
+ 
+ static int
+ sm_clear(staticmethod *sm)
+ {
+ 	Py_XDECREF(sm->sm_callable);
+ 	sm->sm_callable = NULL;
+ 
+ 	return 0;
+ }
+ 
  static PyObject *
  sm_descr_get(PyObject *self, PyObject *obj, PyObject *type)
***************
*** 665,672 ****
  	0,					/* tp_setattro */
  	0,					/* tp_as_buffer */
! 	Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
  	staticmethod_doc,			/* tp_doc */
! 	0,					/* tp_traverse */
! 	0,					/* tp_clear */
  	0,					/* tp_richcompare */
  	0,					/* tp_weaklistoffset */
--- 701,708 ----
  	0,					/* tp_setattro */
  	0,					/* tp_as_buffer */
! 	Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC,
  	staticmethod_doc,			/* tp_doc */
! 	(traverseproc)sm_traverse,		/* tp_traverse */
! 	(inquiry)sm_clear,			/* tp_clear */
  	0,					/* tp_richcompare */
  	0,					/* tp_weaklistoffset */
***************
*** 684,688 ****
  	PyType_GenericAlloc,			/* tp_alloc */
  	PyType_GenericNew,			/* tp_new */
! 	_PyObject_Del,				/* tp_free */
  };
  
--- 720,724 ----
  	PyType_GenericAlloc,			/* tp_alloc */
  	PyType_GenericNew,			/* tp_new */
! 	_PyObject_GC_Del,			/* tp_free */
  };