[Python-checkins] python/dist/src/Modules _sre.c, 2.104, 2.105 sre.h, 2.25, 2.26

rhettinger at users.sourceforge.net rhettinger at users.sourceforge.net
Sun May 30 23:09:28 EDT 2004


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

Modified Files:
	_sre.c sre.h 
Log Message:
Add weakref support to sockets and re pattern objects.



Index: _sre.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/_sre.c,v
retrieving revision 2.104
retrieving revision 2.105
diff -C2 -d -r2.104 -r2.105
*** _sre.c	14 Feb 2004 00:31:13 -0000	2.104
--- _sre.c	31 May 2004 03:09:24 -0000	2.105
***************
*** 1674,1677 ****
--- 1674,1679 ----
      self->indexgroup = indexgroup;
  
+     self->weakreflist = NULL;
+ 
      return (PyObject*) self;
  }
***************
*** 1986,1989 ****
--- 1988,1993 ----
  pattern_dealloc(PatternObject* self)
  {
+     if (self->weakreflist != NULL)
+         PyObject_ClearWeakRefs((PyObject *) self);
      Py_XDECREF(self->pattern);
      Py_XDECREF(self->groupindex);
***************
*** 2633,2636 ****
--- 2637,2641 ----
      memcpy((char*) copy + offset, (char*) self + offset,
             sizeof(PatternObject) + self->codesize * sizeof(SRE_CODE) - offset);
+     copy->weakreflist = NULL;
  
      return (PyObject*) copy;
***************
*** 2723,2727 ****
      (destructor)pattern_dealloc, /*tp_dealloc*/
      0, /*tp_print*/
!     (getattrfunc)pattern_getattr /*tp_getattr*/
  };
  
--- 2728,2750 ----
      (destructor)pattern_dealloc, /*tp_dealloc*/
      0, /*tp_print*/
!     (getattrfunc)pattern_getattr, /*tp_getattr*/
!     0,					/* tp_setattr */
!     0,					/* tp_compare */
!     0,					/* tp_repr */
!     0,					/* tp_as_number */
!     0,					/* tp_as_sequence */
!     0,					/* tp_as_mapping */
!     0,					/* tp_hash */
!     0,					/* tp_call */
!     0,					/* tp_str */
!     0,					/* tp_getattro */
!     0,					/* tp_setattro */
!     0,					/* tp_as_buffer */
!     Py_TPFLAGS_HAVE_WEAKREFS,		/* tp_flags */
!     0,					/* tp_doc */
!     0,					/* tp_traverse */
!     0,					/* tp_clear */
!     0,					/* tp_richcompare */
!     offsetof(PatternObject, weakreflist),	/* tp_weaklistoffset */
  };
  

Index: sre.h
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/sre.h,v
retrieving revision 2.25
retrieving revision 2.26
diff -C2 -d -r2.25 -r2.26
*** sre.h	7 May 2004 07:18:13 -0000	2.25
--- sre.h	31 May 2004 03:09:24 -0000	2.26
***************
*** 30,33 ****
--- 30,34 ----
      PyObject* pattern; /* pattern source (or None) */
      int flags; /* flags used when compiling pattern source */
+     PyObject *weakreflist; /* List of weak references */
      /* pattern code */
      int codesize;




More information about the Python-checkins mailing list