[Python-checkins] CVS: python/dist/src/Objects typeobject.c,2.16.8.44,2.16.8.45

Guido van Rossum gvanrossum@users.sourceforge.net
Mon, 18 Jun 2001 13:17:38 -0700


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

Modified Files:
      Tag: descr-branch
	typeobject.c 
Log Message:
- type_new(): fix a bogus increment in the slotoffset calculation.

- type_new(): DECREF(type) when raising an error.

- PyBaseObject_Type: add a default setattr implementation.


Index: typeobject.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/typeobject.c,v
retrieving revision 2.16.8.44
retrieving revision 2.16.8.45
diff -C2 -r2.16.8.44 -r2.16.8.45
*** typeobject.c	2001/06/18 17:38:41	2.16.8.44
--- typeobject.c	2001/06/18 20:17:36	2.16.8.45
***************
*** 484,489 ****
  	/* Initialize tp_introduced from passed-in dict */
  	type->tp_introduced = dict = PyDict_Copy(dict);
! 	if (dict == NULL)
  		return NULL;
  
  	/* Add descriptors for custom slots from __slots__, or for __dict__ */
--- 484,491 ----
  	/* Initialize tp_introduced from passed-in dict */
  	type->tp_introduced = dict = PyDict_Copy(dict);
! 	if (dict == NULL) {
! 		Py_DECREF(type);
  		return NULL;
+ 	}
  
  	/* Add descriptors for custom slots from __slots__, or for __dict__ */
***************
*** 498,502 ****
  			mp->type = T_OBJECT;
  			mp->offset = slotoffset;
! 			slotoffset += i*sizeof(PyObject *);
  		}
  	}
--- 500,504 ----
  			mp->type = T_OBJECT;
  			mp->offset = slotoffset;
! 			slotoffset += sizeof(PyObject *);
  		}
  	}
***************
*** 525,530 ****
  
  	/* Initialize the rest */
! 	if (PyType_InitDict(type) < 0)
  		return NULL;
  
  	/* Override slots that deserve it */
--- 527,534 ----
  
  	/* Initialize the rest */
! 	if (PyType_InitDict(type) < 0) {
! 		Py_DECREF(type);
  		return NULL;
+ 	}
  
  	/* Override slots that deserve it */
***************
*** 644,648 ****
  	0,					/* tp_str */
  	PyObject_GenericGetAttr,		/* tp_getattro */
! 	0,					/* tp_setattro */
  	0,					/* tp_as_buffer */
  	Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
--- 648,652 ----
  	0,					/* tp_str */
  	PyObject_GenericGetAttr,		/* tp_getattro */
! 	PyObject_GenericSetAttr,		/* tp_setattro */
  	0,					/* tp_as_buffer */
  	Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */