summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2009-08-04 19:16:39 (GMT)
committerRaymond Hettinger <python@rcn.com>2009-08-04 19:16:39 (GMT)
commit54628fa7c093c0734240a99d04b923acdf9e1e9b (patch)
treea37f4b59a856595cb6554f953910f45188bb5591 /Modules
parentfe800a3437b55333dd5d4c21d071c699126830a8 (diff)
downloadcpython-54628fa7c093c0734240a99d04b923acdf9e1e9b.zip
cpython-54628fa7c093c0734240a99d04b923acdf9e1e9b.tar.gz
cpython-54628fa7c093c0734240a99d04b923acdf9e1e9b.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 f8d656c..68e0183 100644
--- a/Modules/_collectionsmodule.c
+++ b/Modules/_collectionsmodule.c
@@ -1170,6 +1170,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);
}
@@ -1316,7 +1319,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;