[Python-checkins] CVS: python/dist/src/Objects typeobject.c,2.42,2.42.2.1
Guido van Rossum
gvanrossum@users.sourceforge.net
Sat, 18 Aug 2001 23:59:51 -0700
- Previous message: [Python-checkins] CVS: python/dist/src/Lib/test test_os.py,1.3,1.3.2.1
- Next message: [Python-checkins] CVS: python/dist/src/Mac/Build AE.carbon.mcp.exp,1.1,NONE AE.carbon.mcp.xml,1.1,NONE App.carbon.mcp.exp,1.1,NONE App.carbon.mcp.xml,1.2,NONE App.mcp.exp,1.1,NONE App.mcp.xml,1.4,NONE CF.carbon.mcp.exp,1.1,NONE CF.carbon.mcp.xml,1.1,NONE Cm.carbon.mcp.exp,1.1,NONE Cm.carbon.mcp.xml,1.2,NONE Cm.mcp.exp,1.1,NONE Cm.mcp.xml,1.4,NONE ColorPicker.carbon.mcp.exp,1.1,NONE ColorPicker.carbon.mcp.xml,1.2,NONE ColorPicker.mcp.exp,1.1,NONE ColorPicker.mcp.xml,1.4,NONE Ctl.carbon.mcp.exp,1.1,NONE Ctl.carbon.mcp.xml,1.1,NONE Ctl.mcp.exp,1.1,NONE Ctl.mcp.xml,1.1,NONE Dlg.carbon.mcp.exp,1.1,NONE Dlg.carbon.mcp.xml,1.1,NONE Dlg.mcp.exp,1.1,NONE Dlg.mcp.xml,1.1,NONE Drag.carbon.mcp.exp,1.1,NONE Drag.carbon.mcp.xml,1.1,NONE Drag.mcp.exp,1.3,NONE Drag.mcp.xml,1.3,NONE Evt.carbon.mcp.exp,1.1,NONE Evt.carbon.mcp.xml,1.1,NONE Evt.mcp.exp,1.1,NONE Evt.mcp.xml,1.1,NONE Fm.carbon.mcp.exp,1.1,NONE Fm.carbon.mcp.xml,1.2,NONE Fm.mcp.exp,1.1,NONE Fm.mcp.xml,1.4,NONE Help.mcp.exp,1.1,NONE Help.mcp.xml,1.4,NONE HtmlRender.prj.exp,1.1,NONE Icn.carbon.mcp.exp,1.1,NONE Icn.carbon.mcp.xml,1.2,NONE Icn.mcp.exp,1.1,NONE Icn.mcp.xml,1.4,NONE List.carbon.mcp.exp,1.1,NONE List.carbon.mcp.xml,1.2,NONE List.mcp.exp,1.1,NONE List.mcp.xml,1.4,NONE Menu.carbon.mcp.exp,1.1,NONE Menu.carbon.mcp.xml,1.1,NONE Menu.mcp.exp,1.1,NONE Menu.mcp.xml,1.1,NONE Mlte.carbon.mcp.exp,1.1,NONE Mlte.carbon.mcp.xml,1.1,NONE Mlte.mcp.exp,1.1,NONE Mlte.mcp.xml,1.1,NONE Printing.mcp.exp,1.1,NONE Printing.mcp.xml,1.4,NONE Qd.carbon.mcp.exp,1.1,NONE Qd.carbon.mcp.xml,1.1,NONE Qd.mcp.exp,1.1,NONE Qd.mcp.xml,1.1,NONE Qdoffs.carbon.mcp.exp,1.1,NONE Qdoffs.carbon.mcp.xml,1.2,NONE Qdoffs.mcp.exp,1.2,NONE Qdoffs.mcp.xml,1.4,NONE Qt.carbon.mcp.exp,1.1,NONE Qt.carbon.mcp.xml,1.2,NONE Qt.mcp.exp,1.1,NONE Qt.mcp.xml,1.5,NONE Res.carbon.mcp.exp,1.1,NONE Res.carbon.mcp.xml,1.1,NONE Res.mcp.exp,1.1,NONE Res.mcp.xml,1.1,NONE Scrap.carbon.mcp.exp,1.1,NONE Scrap.carbon.mcp.xml,1.1,NONE Scrap.mcp.exp,1.1,NONE Scrap.mcp.xml,1.4,NONE Snd.carbon.mcp.exp,1.1,NONE Snd.carbon.mcp.xml,1.2,NONE Snd.mcp.exp,1.1,NONE Snd.mcp.xml,1.4,NONE Sndihooks.carbon.mcp.exp,1.1,NONE Sndihooks.carbon.mcp.xml,1.2,NONE Sndihooks.mcp.exp,1.1,NONE Sndihooks.mcp.xml,1.4,NONE TE.carbon.mcp.exp,1.1,NONE TE.carbon.mcp.xml,1.2,NONE TE.mcp.exp,1.1,NONE TE.mcp.xml,1.4,NONE Win.carbon.mcp.exp,1.1,NONE Win.carbon.mcp.xml,1.1,NONE Win.mcp.exp,1.1,NONE Win.mcp.xml,1.1,NONE _dummy_tkinter.mcp.exp,1.1,NONE _symtable.carbon.mcp.exp,1.1,NONE _symtable.carbon.mcp.xml,1.1,NONE _symtable.mcp.exp,1.1,NONE _symtable.mcp.xml,1.1,NONE _testcapi.carbon.mcp.exp,1.1,NONE _testcapi.carbon.mcp.xml,1.1,NONE _testcapi.mcp.exp,1.1,NONE _testcapi.mcp.xml,1.1,NONE _weakref.carbon.mcp.exp,1.1,NONE _weakref.carbon.mcp.xml,1.1,NONE _weakref.mcp.exp,1.1,NONE _weakref.mcp.xml,1.1,NONE calldll.carbon.mcp.exp,1.1,NONE calldll.carbon.mcp.xml,1.2,NONE calldll.mcp.exp,1.1,NONE calldll.mcp.xml,1.4,NONE ctb.mcp.exp,1.1,NONE ctb.mcp.xml,1.4,NONE gdbm.carbon.mcp.exp,1.1,NONE gdbm.carbon.mcp.xml,1.2,NONE gdbm.mcp.exp,1.1,NONE gdbm.mcp.xml,1.4,NONE icglue.carbon.mcp.exp,1.1,NONE icglue.carbon.mcp.xml,1.1,NONE icglue.mcp.exp,1.1,NONE icglue.mcp.xml,1.4,NONE macspeech.mcp.exp,1.1,NONE macspeech.mcp.xml,1.4,NONE pyexpat.carbon.mcp.exp,1.1,NONE pyexpat.carbon.mcp.xml,1.2,NONE pyexpat.mcp.exp,1.1,NONE pyexpat.mcp.xml,1.4,NONE waste.carbon.mcp.exp,1.1,NONE waste.carbon.mcp.xml,1.1,NONE waste.mcp.exp,1.1,NONE waste.mcp.xml,1.4,NONE xx.prj.exp,1.1,NONE zlib.carbon.mcp.exp,1.1,NONE zlib.carbon.mcp.xml,1.2,NONE zlib.mcp.exp,1.1,NONE zlib.mcp.xml,1.4,NONE
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvsroot/python/python/dist/src/Objects
In directory usw-pr-cvs1:/tmp/cvs-serv11697
Modified Files:
Tag: r22a2-branch
typeobject.c
Log Message:
Address SF bug #452832.
tp_new_wrapper(): add safety test to __new__ so that you can't do
something unsafe like object.__new__(type) or
object.__new__(dictionary), while still allowing
e.g. dictionary.__new__(X) where X is a subclass of dictionary.
Also improved the other error messages in the same function to give
the type name(s) involved.
Index: typeobject.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/typeobject.c,v
retrieving revision 2.42
retrieving revision 2.42.2.1
diff -C2 -d -r2.42 -r2.42.2.1
*** typeobject.c 2001/08/17 21:57:47 2.42
--- typeobject.c 2001/08/19 06:59:49 2.42.2.1
***************
*** 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)
- Previous message: [Python-checkins] CVS: python/dist/src/Lib/test test_os.py,1.3,1.3.2.1
- Next message: [Python-checkins] CVS: python/dist/src/Mac/Build AE.carbon.mcp.exp,1.1,NONE AE.carbon.mcp.xml,1.1,NONE App.carbon.mcp.exp,1.1,NONE App.carbon.mcp.xml,1.2,NONE App.mcp.exp,1.1,NONE App.mcp.xml,1.4,NONE CF.carbon.mcp.exp,1.1,NONE CF.carbon.mcp.xml,1.1,NONE Cm.carbon.mcp.exp,1.1,NONE Cm.carbon.mcp.xml,1.2,NONE Cm.mcp.exp,1.1,NONE Cm.mcp.xml,1.4,NONE ColorPicker.carbon.mcp.exp,1.1,NONE ColorPicker.carbon.mcp.xml,1.2,NONE ColorPicker.mcp.exp,1.1,NONE ColorPicker.mcp.xml,1.4,NONE Ctl.carbon.mcp.exp,1.1,NONE Ctl.carbon.mcp.xml,1.1,NONE Ctl.mcp.exp,1.1,NONE Ctl.mcp.xml,1.1,NONE Dlg.carbon.mcp.exp,1.1,NONE Dlg.carbon.mcp.xml,1.1,NONE Dlg.mcp.exp,1.1,NONE Dlg.mcp.xml,1.1,NONE Drag.carbon.mcp.exp,1.1,NONE Drag.carbon.mcp.xml,1.1,NONE Drag.mcp.exp,1.3,NONE Drag.mcp.xml,1.3,NONE Evt.carbon.mcp.exp,1.1,NONE Evt.carbon.mcp.xml,1.1,NONE Evt.mcp.exp,1.1,NONE Evt.mcp.xml,1.1,NONE Fm.carbon.mcp.exp,1.1,NONE Fm.carbon.mcp.xml,1.2,NONE Fm.mcp.exp,1.1,NONE Fm.mcp.xml,1.4,NONE Help.mcp.exp,1.1,NONE Help.mcp.xml,1.4,NONE HtmlRender.prj.exp,1.1,NONE Icn.carbon.mcp.exp,1.1,NONE Icn.carbon.mcp.xml,1.2,NONE Icn.mcp.exp,1.1,NONE Icn.mcp.xml,1.4,NONE List.carbon.mcp.exp,1.1,NONE List.carbon.mcp.xml,1.2,NONE List.mcp.exp,1.1,NONE List.mcp.xml,1.4,NONE Menu.carbon.mcp.exp,1.1,NONE Menu.carbon.mcp.xml,1.1,NONE Menu.mcp.exp,1.1,NONE Menu.mcp.xml,1.1,NONE Mlte.carbon.mcp.exp,1.1,NONE Mlte.carbon.mcp.xml,1.1,NONE Mlte.mcp.exp,1.1,NONE Mlte.mcp.xml,1.1,NONE Printing.mcp.exp,1.1,NONE Printing.mcp.xml,1.4,NONE Qd.carbon.mcp.exp,1.1,NONE Qd.carbon.mcp.xml,1.1,NONE Qd.mcp.exp,1.1,NONE Qd.mcp.xml,1.1,NONE Qdoffs.carbon.mcp.exp,1.1,NONE Qdoffs.carbon.mcp.xml,1.2,NONE Qdoffs.mcp.exp,1.2,NONE Qdoffs.mcp.xml,1.4,NONE Qt.carbon.mcp.exp,1.1,NONE Qt.carbon.mcp.xml,1.2,NONE Qt.mcp.exp,1.1,NONE Qt.mcp.xml,1.5,NONE Res.carbon.mcp.exp,1.1,NONE Res.carbon.mcp.xml,1.1,NONE Res.mcp.exp,1.1,NONE Res.mcp.xml,1.1,NONE Scrap.carbon.mcp.exp,1.1,NONE Scrap.carbon.mcp.xml,1.1,NONE Scrap.mcp.exp,1.1,NONE Scrap.mcp.xml,1.4,NONE Snd.carbon.mcp.exp,1.1,NONE Snd.carbon.mcp.xml,1.2,NONE Snd.mcp.exp,1.1,NONE Snd.mcp.xml,1.4,NONE Sndihooks.carbon.mcp.exp,1.1,NONE Sndihooks.carbon.mcp.xml,1.2,NONE Sndihooks.mcp.exp,1.1,NONE Sndihooks.mcp.xml,1.4,NONE TE.carbon.mcp.exp,1.1,NONE TE.carbon.mcp.xml,1.2,NONE TE.mcp.exp,1.1,NONE TE.mcp.xml,1.4,NONE Win.carbon.mcp.exp,1.1,NONE Win.carbon.mcp.xml,1.1,NONE Win.mcp.exp,1.1,NONE Win.mcp.xml,1.1,NONE _dummy_tkinter.mcp.exp,1.1,NONE _symtable.carbon.mcp.exp,1.1,NONE _symtable.carbon.mcp.xml,1.1,NONE _symtable.mcp.exp,1.1,NONE _symtable.mcp.xml,1.1,NONE _testcapi.carbon.mcp.exp,1.1,NONE _testcapi.carbon.mcp.xml,1.1,NONE _testcapi.mcp.exp,1.1,NONE _testcapi.mcp.xml,1.1,NONE _weakref.carbon.mcp.exp,1.1,NONE _weakref.carbon.mcp.xml,1.1,NONE _weakref.mcp.exp,1.1,NONE _weakref.mcp.xml,1.1,NONE calldll.carbon.mcp.exp,1.1,NONE calldll.carbon.mcp.xml,1.2,NONE calldll.mcp.exp,1.1,NONE calldll.mcp.xml,1.4,NONE ctb.mcp.exp,1.1,NONE ctb.mcp.xml,1.4,NONE gdbm.carbon.mcp.exp,1.1,NONE gdbm.carbon.mcp.xml,1.2,NONE gdbm.mcp.exp,1.1,NONE gdbm.mcp.xml,1.4,NONE icglue.carbon.mcp.exp,1.1,NONE icglue.carbon.mcp.xml,1.1,NONE icglue.mcp.exp,1.1,NONE icglue.mcp.xml,1.4,NONE macspeech.mcp.exp,1.1,NONE macspeech.mcp.xml,1.4,NONE pyexpat.carbon.mcp.exp,1.1,NONE pyexpat.carbon.mcp.xml,1.2,NONE pyexpat.mcp.exp,1.1,NONE pyexpat.mcp.xml,1.4,NONE waste.carbon.mcp.exp,1.1,NONE waste.carbon.mcp.xml,1.1,NONE waste.mcp.exp,1.1,NONE waste.mcp.xml,1.4,NONE xx.prj.exp,1.1,NONE zlib.carbon.mcp.exp,1.1,NONE zlib.carbon.mcp.xml,1.2,NONE zlib.mcp.exp,1.1,NONE zlib.mcp.xml,1.4,NONE
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]