diff options
author | Georg Brandl <georg@python.org> | 2007-03-06 13:32:52 (GMT) |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2007-03-06 13:32:52 (GMT) |
commit | b51a57eb3233c99170c5f7c48daff822ab4c0fdf (patch) | |
tree | 8dbee4c57ffed2da759ed0a007ada5911fcb7708 /Modules | |
parent | 098cd69ff9fe8f78753a86d0c17b0c87b0a13587 (diff) | |
download | cpython-b51a57eb3233c99170c5f7c48daff822ab4c0fdf.zip cpython-b51a57eb3233c99170c5f7c48daff822ab4c0fdf.tar.gz cpython-b51a57eb3233c99170c5f7c48daff822ab4c0fdf.tar.bz2 |
Fix another reincarnation of bug #1576657 in defaultdict.
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/_collectionsmodule.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/Modules/_collectionsmodule.c b/Modules/_collectionsmodule.c index c37f9ac..c70019c 100644 --- a/Modules/_collectionsmodule.c +++ b/Modules/_collectionsmodule.c @@ -1075,7 +1075,7 @@ static PyTypeObject defdict_type; /* Forward */ PyDoc_STRVAR(defdict_missing_doc, "__missing__(key) # Called by __getitem__ for missing key; pseudo-code:\n\ - if self.default_factory is None: raise KeyError(key)\n\ + if self.default_factory is None: raise KeyError((key,))\n\ self[key] = value = self.default_factory()\n\ return value\n\ "); @@ -1087,7 +1087,11 @@ defdict_missing(defdictobject *dd, PyObject *key) PyObject *value; if (factory == NULL || factory == Py_None) { /* XXX Call dict.__missing__(key) */ - PyErr_SetObject(PyExc_KeyError, key); + PyObject *tup; + tup = PyTuple_Pack(1, key); + if (!tup) return NULL; + PyErr_SetObject(PyExc_KeyError, tup); + Py_DECREF(tup); return NULL; } value = PyEval_CallObject(factory, NULL); |