[Python-checkins] CVS: python/dist/src/Objects typeobject.c,2.42,2.43
Barry Warsaw
bwarsaw@users.sourceforge.net
Wed, 22 Aug 2001 12:24:45 -0700
Update of /cvsroot/python/python/dist/src/Objects
In directory usw-pr-cvs1:/tmp/cvs-serv12169/Objects
Modified Files:
typeobject.c
Log Message:
Merge changes from r22a2-branch back into trunk. Also, change patch
level to 2.2a2+
Index: typeobject.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/typeobject.c,v
retrieving revision 2.42
retrieving revision 2.43
diff -C2 -d -r2.42 -r2.43
*** typeobject.c 2001/08/17 21:57:47 2.42
--- typeobject.c 2001/08/22 19:24:42 2.43
***************
*** 2092,2096 ****
tp_new_wrapper(PyObject *self, PyObject *args, PyObject *kwds)
{
! PyTypeObject *type, *subtype;
PyObject *arg0, *res;
--- 2092,2096 ----
tp_new_wrapper(PyObject *self, PyObject *args, PyObject *kwds)
{
! PyTypeObject *type, *subtype, *staticbase;
PyObject *arg0, *res;
***************
*** 2099,2118 ****
type = (PyTypeObject *)self;
if (!PyTuple_Check(args) || PyTuple_GET_SIZE(args) < 1) {
! PyErr_SetString(PyExc_TypeError,
! "T.__new__(): not enough arguments");
return NULL;
}
arg0 = PyTuple_GET_ITEM(args, 0);
if (!PyType_Check(arg0)) {
! PyErr_SetString(PyExc_TypeError,
! "T.__new__(S): S is not a type object");
return NULL;
}
subtype = (PyTypeObject *)arg0;
if (!PyType_IsSubtype(subtype, type)) {
! PyErr_SetString(PyExc_TypeError,
! "T.__new__(S): S is not a subtype of T");
return NULL;
}
args = PyTuple_GetSlice(args, 1, PyTuple_GET_SIZE(args));
if (args == NULL)
--- 2099,2141 ----
type = (PyTypeObject *)self;
if (!PyTuple_Check(args) || PyTuple_GET_SIZE(args) < 1) {
! PyErr_Format(PyExc_TypeError,
! "%s.__new__(): not enough arguments",
! type->tp_name);
return NULL;
}
arg0 = PyTuple_GET_ITEM(args, 0);
if (!PyType_Check(arg0)) {
! PyErr_Format(PyExc_TypeError,
! "%s.__new__(X): X is not a type object (%s)",
! type->tp_name,
! arg0->ob_type->tp_name);
return NULL;
}
subtype = (PyTypeObject *)arg0;
if (!PyType_IsSubtype(subtype, type)) {
! PyErr_Format(PyExc_TypeError,
! "%s.__new__(%s): %s is not a subtype of %s",
! type->tp_name,
! subtype->tp_name,
! subtype->tp_name,
! type->tp_name);
! return NULL;
! }
!
! /* Check that the use doesn't do something silly and unsafe like
! object.__new__(dictionary). To do this, we check that the
! most derived base that's not a heap type is this type. */
! staticbase = subtype;
! while (staticbase && (staticbase->tp_flags & Py_TPFLAGS_HEAPTYPE))
! staticbase = staticbase->tp_base;
! if (staticbase != type) {
! PyErr_Format(PyExc_TypeError,
! "%s.__new__(%s) is not safe, use %s.__new__()",
! type->tp_name,
! subtype->tp_name,
! staticbase == NULL ? "?" : staticbase->tp_name);
return NULL;
}
+
args = PyTuple_GetSlice(args, 1, PyTuple_GET_SIZE(args));
if (args == NULL)