[Python-checkins] python/dist/src/Modules arraymodule.c,2.95,2.96

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


Update of /cvsroot/python/python/dist/src/Modules
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10541/Modules
Modified Files:
	arraymodule.c 
Log Message:
Add weakref support to array.array and file objects.
Index: arraymodule.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/arraymodule.c,v
retrieving revision 2.95
retrieving revision 2.96
diff -C2 -d -r2.95 -r2.96
*** arraymodule.c	14 Mar 2004 05:43:59 -0000	2.95
--- arraymodule.c	31 May 2004 00:35:52 -0000	2.96
***************
*** 5,8 ****
--- 5,9 ----
 
 #include "Python.h"
+ #include "structmember.h"
 
 #ifdef STDC_HEADERS
***************
*** 33,36 ****
--- 34,38 ----
 	int allocated;
 	struct arraydescr *ob_descr;
+ 	PyObject *weakreflist; /* List of weak references */
 } arrayobject;
 
***************
*** 443,446 ****
--- 445,449 ----
 	op->ob_descr = descr;
 	op->allocated = size;
+ 	op->weakreflist = NULL;
 	return (PyObject *) op;
 }
***************
*** 491,494 ****
--- 494,499 ----
 array_dealloc(arrayobject *op)
 {
+ 	if (op->weakreflist != NULL)
+ 		PyObject_ClearWeakRefs((PyObject *) op);
 	if (op->ob_item != NULL)
 		PyMem_DEL(op->ob_item);
***************
*** 1951,1960 ****
 	0,					/* tp_setattro */
 	&array_as_buffer,			/* tp_as_buffer*/
! 	Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
 	arraytype_doc,				/* tp_doc */
 	0,					/* tp_traverse */
 	0,					/* tp_clear */
 	array_richcompare,			/* tp_richcompare */
! 	0,					/* tp_weaklistoffset */
 	(getiterfunc)array_iter,		/* tp_iter */
 	0,					/* tp_iternext */
--- 1956,1965 ----
 	0,					/* tp_setattro */
 	&array_as_buffer,			/* tp_as_buffer*/
! 	Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_WEAKREFS, /* tp_flags */
 	arraytype_doc,				/* tp_doc */
 	0,					/* tp_traverse */
 	0,					/* tp_clear */
 	array_richcompare,			/* tp_richcompare */
! 	offsetof(arrayobject, weakreflist),	/* tp_weaklistoffset */
 	(getiterfunc)array_iter,		/* tp_iter */
 	0,					/* tp_iternext */


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /