Commit b51a57eb authored by Georg Brandl's avatar Georg Brandl

Fix another reincarnation of bug #1576657 in defaultdict.

parent 098cd69f
...@@ -1075,7 +1075,7 @@ static PyTypeObject defdict_type; /* Forward */ ...@@ -1075,7 +1075,7 @@ static PyTypeObject defdict_type; /* Forward */
PyDoc_STRVAR(defdict_missing_doc, PyDoc_STRVAR(defdict_missing_doc,
"__missing__(key) # Called by __getitem__ for missing key; pseudo-code:\n\ "__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\ self[key] = value = self.default_factory()\n\
return value\n\ return value\n\
"); ");
...@@ -1087,7 +1087,11 @@ defdict_missing(defdictobject *dd, PyObject *key) ...@@ -1087,7 +1087,11 @@ defdict_missing(defdictobject *dd, PyObject *key)
PyObject *value; PyObject *value;
if (factory == NULL || factory == Py_None) { if (factory == NULL || factory == Py_None) {
/* XXX Call dict.__missing__(key) */ /* 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; return NULL;
} }
value = PyEval_CallObject(factory, NULL); value = PyEval_CallObject(factory, NULL);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment