summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2008-02-09 04:37:49 (GMT)
committerRaymond Hettinger <python@rcn.com>2008-02-09 04:37:49 (GMT)
commit17a74c395eafa98e7dcdeaa8a48110e95b142b66 (patch)
tree971dcfcf56ead21ef19b6576205e99babfe54c8d /Modules
parent2e827bfdfea7b940517f90af78c986aec9159d2c (diff)
downloadcpython-17a74c395eafa98e7dcdeaa8a48110e95b142b66.zip
cpython-17a74c395eafa98e7dcdeaa8a48110e95b142b66.tar.gz
cpython-17a74c395eafa98e7dcdeaa8a48110e95b142b66.tar.bz2
Add -3 warnings that set.copy(), dict.copy(), and defaultdict.copy() will go away in Py3.x
Diffstat (limited to 'Modules')
-rw-r--r--Modules/_collectionsmodule.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/Modules/_collectionsmodule.c b/Modules/_collectionsmodule.c
index 67700de..9cdabdf 100644
--- a/Modules/_collectionsmodule.c
+++ b/Modules/_collectionsmodule.c
@@ -1186,13 +1186,23 @@ defdict_copy(defdictobject *dd)
{
/* This calls the object's class. That only works for subclasses
whose class constructor has the same signature. Subclasses that
- define a different constructor signature must override copy().
+ define a different constructor signature must override __copy__().
*/
return PyObject_CallFunctionObjArgs((PyObject*)Py_TYPE(dd),
dd->default_factory, dd, NULL);
}
static PyObject *
+defdict_copy_method(defdictobject *dd)
+{
+ if (Py_Py3kWarningFlag &&
+ PyErr_Warn(PyExc_DeprecationWarning,
+ "defaultdict.copy() not supported in 3.x") < 0)
+ return NULL;
+ return defdict_copy(dd);
+}
+
+static PyObject *
defdict_reduce(defdictobject *dd)
{
/* __reduce__ must return a 5-tuple as follows:
@@ -1241,7 +1251,7 @@ defdict_reduce(defdictobject *dd)
static PyMethodDef defdict_methods[] = {
{"__missing__", (PyCFunction)defdict_missing, METH_O,
defdict_missing_doc},
- {"copy", (PyCFunction)defdict_copy, METH_NOARGS,
+ {"copy", (PyCFunction)defdict_copy_method, METH_NOARGS,
defdict_copy_doc},
{"__copy__", (PyCFunction)defdict_copy, METH_NOARGS,
defdict_copy_doc},