[Python-checkins] r54161 - python/branches/release25-maint/Modules/collectionsmodule.c
georg.brandl
python-checkins at python.org
Tue Mar 6 14:33:07 CET 2007
Author: georg.brandl
Date: Tue Mar 6 14:33:07 2007
New Revision: 54161
Modified:
python/branches/release25-maint/Modules/collectionsmodule.c
Log:
Fix another reincarnation of bug #1576657 in defaultdict.
(backport from rev. 54160)
Modified: python/branches/release25-maint/Modules/collectionsmodule.c
==============================================================================
--- python/branches/release25-maint/Modules/collectionsmodule.c (original)
+++ python/branches/release25-maint/Modules/collectionsmodule.c Tue Mar 6 14:33:07 2007
@@ -1075,7 +1075,7 @@
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 @@
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);
More information about the Python-checkins
mailing list