[Python-checkins] CVS: python/dist/src/Modules pyexpat.c,2.50,2.51

Martin v. L?wis loewis@users.sourceforge.net
Sun, 23 Sep 2001 03:20:12 -0700


Update of /cvsroot/python/python/dist/src/Modules
In directory usw-pr-cvs1:/tmp/cvs-serv304

Modified Files:
	pyexpat.c 
Log Message:
Reactivate participation of expat parsers in GC. Fixes bug #462710.


Index: pyexpat.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/pyexpat.c,v
retrieving revision 2.50
retrieving revision 2.51
diff -C2 -d -r2.50 -r2.51
*** pyexpat.c	2001/09/19 10:37:50	2.50
--- pyexpat.c	2001/09/23 10:20:10	2.51
***************
*** 978,983 ****
      new_parser = PyObject_NEW(xmlparseobject, &Xmlparsetype);
  #else
!     /* Python versions 1.6 and later */
      new_parser = PyObject_New(xmlparseobject, &Xmlparsetype);
  #endif
  
--- 978,988 ----
      new_parser = PyObject_NEW(xmlparseobject, &Xmlparsetype);
  #else
! #ifndef Py_TPFLAGS_HAVE_GC
!     /* Python versions 1.6 to 2.1 */
      new_parser = PyObject_New(xmlparseobject, &Xmlparsetype);
+ #else
+     /* Python versions 2.2 and later */
+     new_parser = PyObject_GC_New(xmlparseobject, &Xmlparsetype);
+ #endif
  #endif
  
***************
*** 991,995 ****
--- 996,1004 ----
  							encoding);
      new_parser->handlers = 0;
+ #ifdef Py_TPFLAGS_HAVE_GC
+     PyObject_GC_Track(new_parser);
+ #else
      PyObject_GC_Init(new_parser);
+ #endif
  
      if (!new_parser->itself) {
***************
*** 1140,1144 ****
--- 1149,1158 ----
  #else
      /* Code for versions 1.6 and later */
+ #ifdef Py_TPFLAGS_HAVE_GC
+     /* Code for versions 2.2 and later */
+     self = PyObject_GC_New(xmlparseobject, &Xmlparsetype);
+ #else
      self = PyObject_New(xmlparseobject, &Xmlparsetype);
+ #endif
      if (self == NULL)
          return NULL;
***************
*** 1156,1160 ****
--- 1170,1178 ----
          self->itself = XML_ParserCreate(encoding);
      }
+ #ifdef Py_TPFLAGS_HAVE_GC
+     PyObject_GC_Track(self);
+ #else
      PyObject_GC_Init(self);
+ #endif
      if (self->itself == NULL) {
          PyErr_SetString(PyExc_RuntimeError, 
***************
*** 1186,1190 ****
--- 1204,1212 ----
  {
      int i;
+ #ifdef Py_TPFLAGS_HAVE_GC
+     PyObject_GC_UnTrack(self);
+ #else
      PyObject_GC_Fini(self);
+ #endif
      if (self->itself != NULL)
          XML_ParserFree(self->itself);
***************
*** 1204,1209 ****
      free(self);
  #else
!     /* Code for versions 1.6 and later */
      PyObject_Del(self);
  #endif
  }
--- 1226,1236 ----
      free(self);
  #else
! #ifndef Py_TPFLAGS_HAVE_GC
!     /* Code for versions 1.6 to 2.1 */
      PyObject_Del(self);
+ #else
+     /* Code for versions 2.2 and later. */
+     PyObject_GC_Del(self);
+ #endif
  #endif
  }
***************
*** 1371,1375 ****
--- 1398,1406 ----
  	0,		/* tp_setattro */
  	0,		/* tp_as_buffer */
+ #ifdef Py_TPFLAGS_HAVE_GC
+ 	Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, /*tp_flags*/	
+ #else
  	Py_TPFLAGS_DEFAULT | Py_TPFLAGS_GC, /*tp_flags*/	
+ #endif
  	Xmlparsetype__doc__, /* Documentation string */
  #ifdef WITH_CYCLE_GC