[Python-checkins] python/dist/src/Objects fileobject.c,2.190,2.191

rhettinger at users.sourceforge.net rhettinger at users.sourceforge.net
Sun May 30 20:35:54 EDT 2004


Update of /cvsroot/python/python/dist/src/Objects
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10541/Objects

Modified Files:
	fileobject.c 
Log Message:
Add weakref support to array.array and file objects.



Index: fileobject.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/fileobject.c,v
retrieving revision 2.190
retrieving revision 2.191
diff -C2 -d -r2.190 -r2.191
*** fileobject.c	4 Apr 2004 06:58:27 -0000	2.190
--- fileobject.c	31 May 2004 00:35:51 -0000	2.191
***************
*** 308,311 ****
--- 308,313 ----
  file_dealloc(PyFileObject *f)
  {
+ 	if (f->weakreflist != NULL)
+ 		PyObject_ClearWeakRefs((PyObject *) f);
  	if (f->f_fp != NULL && f->f_close != NULL) {
  		Py_BEGIN_ALLOW_THREADS
***************
*** 1822,1825 ****
--- 1824,1828 ----
  		Py_INCREF(Py_None);
  		((PyFileObject *)self)->f_encoding = Py_None;
+ 		((PyFileObject *)self)->weakreflist = NULL;
  	}
  	return self;
***************
*** 1943,1952 ****
  	PyObject_GenericSetAttr,		/* tp_setattro */
  	0,					/* tp_as_buffer */
! 	Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
  	file_doc,				/* tp_doc */
  	0,					/* tp_traverse */
  	0,					/* tp_clear */
  	0,					/* tp_richcompare */
! 	0,					/* tp_weaklistoffset */
  	(getiterfunc)file_getiter,		/* tp_iter */
  	(iternextfunc)file_iternext,		/* tp_iternext */
--- 1946,1955 ----
  	PyObject_GenericSetAttr,		/* tp_setattro */
  	0,					/* tp_as_buffer */
! 	Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_WEAKREFS, /* tp_flags */
  	file_doc,				/* tp_doc */
  	0,					/* tp_traverse */
  	0,					/* tp_clear */
  	0,					/* tp_richcompare */
! 	offsetof(PyFileObject, weakreflist),	/* tp_weaklistoffset */
  	(getiterfunc)file_getiter,		/* tp_iter */
  	(iternextfunc)file_iternext,		/* tp_iternext */




More information about the Python-checkins mailing list