diff options
author | Raymond Hettinger <python@rcn.com> | 2002-12-04 07:32:25 (GMT) |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2002-12-04 07:32:25 (GMT) |
commit | b02bb5ed0a45571c3be195cd053bb28e408a99cd (patch) | |
tree | d42cba22585a0e578fb78e1473bf377a398891b3 /Objects | |
parent | 21d77f5e9cd77c4fb45038ed778306a1ec4ecfb9 (diff) | |
download | cpython-b02bb5ed0a45571c3be195cd053bb28e408a99cd.zip cpython-b02bb5ed0a45571c3be195cd053bb28e408a99cd.tar.gz cpython-b02bb5ed0a45571c3be195cd053bb28e408a99cd.tar.bz2 |
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.
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/dictobject.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/Objects/dictobject.c b/Objects/dictobject.c index eca8677..d3603f0 100644 --- a/Objects/dictobject.c +++ b/Objects/dictobject.c @@ -973,15 +973,16 @@ dict_fromkeys(PyObject *mp, PyObject *args) PyObject *cls; int status; - if (!PyArg_ParseTuple(args, "OO|O:fromkeys", &cls, &seq, &value)) + if (!PyArg_ParseTuple(args, "OO|O:fromkeys", &cls, &seq, &value)) return NULL; d = PyObject_CallObject(cls, NULL); if (d == NULL) return NULL; if (!PyDict_Check(d)) { - PyErr_BadInternalCall(); Py_DECREF(d); + PyErr_SetString(PyExc_TypeError, + "class constructor must return a subclass of dict"); return NULL; } |