[Python-checkins] python/dist/src/Objects dictobject.c,2.133,2.134
rhettinger@users.sourceforge.net
rhettinger@users.sourceforge.net
Tue, 03 Dec 2002 23:32:28 -0800
- Previous message: [Python-checkins] python/nondist/sandbox/datetime datetime.c,1.39,1.40 obj_date.c,1.19,1.20 obj_datetime.c,1.14,1.15 obj_delta.c,1.20,1.21
- Next message: [Python-checkins] python/dist/src/Lib/test test_types.py,1.41,1.42
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvsroot/python/python/dist/src/Objects
In directory sc8-pr-cvs1:/tmp/cvs-serv25529/Objects
Modified Files:
dictobject.c
Log Message:
Replace BadInternalCall with TypeError. Add a test case. Fix whitespace.
Just van Rossum showed a weird, but clever way for pure python code to
trigger the BadInternalCall. The C code had assumed that calling a class
constructor would return an instance of that class; however, classes that
abuse __new__ can invalidate that assumption.
Index: dictobject.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/dictobject.c,v
retrieving revision 2.133
retrieving revision 2.134
diff -C2 -d -r2.133 -r2.134
*** dictobject.c 27 Nov 2002 19:38:00 -0000 2.133
--- dictobject.c 4 Dec 2002 07:32:25 -0000 2.134
***************
*** 974,978 ****
int status;
! if (!PyArg_ParseTuple(args, "OO|O:fromkeys", &cls, &seq, &value))
return NULL;
--- 974,978 ----
int status;
! if (!PyArg_ParseTuple(args, "OO|O:fromkeys", &cls, &seq, &value))
return NULL;
***************
*** 981,986 ****
return NULL;
if (!PyDict_Check(d)) {
- PyErr_BadInternalCall();
Py_DECREF(d);
return NULL;
}
--- 981,987 ----
return NULL;
if (!PyDict_Check(d)) {
Py_DECREF(d);
+ PyErr_SetString(PyExc_TypeError,
+ "class constructor must return a subclass of dict");
return NULL;
}
- Previous message: [Python-checkins] python/nondist/sandbox/datetime datetime.c,1.39,1.40 obj_date.c,1.19,1.20 obj_datetime.c,1.14,1.15 obj_delta.c,1.20,1.21
- Next message: [Python-checkins] python/dist/src/Lib/test test_types.py,1.41,1.42
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]