summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2009-08-04 18:49:26 (GMT)
committerRaymond Hettinger <python@rcn.com>2009-08-04 18:49:26 (GMT)
commitd6119ef883b7510850a55b9e2a48bd7110db981f (patch)
tree3913741e806be7e5826d093f888b0527bf6daf1e /Modules
parent6416f810e88f2def05b85e6215a4804c6997d730 (diff)
downloadcpython-d6119ef883b7510850a55b9e2a48bd7110db981f.zip
cpython-d6119ef883b7510850a55b9e2a48bd7110db981f.tar.gz
cpython-d6119ef883b7510850a55b9e2a48bd7110db981f.tar.bz2
Issue 6637: defaultdict.copy() failed with an empty factory.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/_collectionsmodule.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/Modules/_collectionsmodule.c b/Modules/_collectionsmodule.c
index 0029532..faf033e 100644
--- a/Modules/_collectionsmodule.c
+++ b/Modules/_collectionsmodule.c
@@ -1191,6 +1191,9 @@ defdict_copy(defdictobject *dd)
whose class constructor has the same signature. Subclasses that
define a different constructor signature must override copy().
*/
+
+ if (dd->default_factory == NULL)
+ return PyObject_CallFunctionObjArgs((PyObject*)Py_TYPE(dd), Py_None, dd, NULL);
return PyObject_CallFunctionObjArgs((PyObject*)Py_TYPE(dd),
dd->default_factory, dd, NULL);
}
@@ -1354,7 +1357,7 @@ defdict_init(PyObject *self, PyObject *args, PyObject *kwds)
Py_ssize_t n = PyTuple_GET_SIZE(args);
if (n > 0) {
newdefault = PyTuple_GET_ITEM(args, 0);
- if (!PyCallable_Check(newdefault)) {
+ if (!PyCallable_Check(newdefault) && newdefault != Py_None) {
PyErr_SetString(PyExc_TypeError,
"first argument must be callable");
return -1;