diff options
author | Raymond Hettinger <python@rcn.com> | 2008-02-09 04:37:49 (GMT) |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2008-02-09 04:37:49 (GMT) |
commit | 17a74c395eafa98e7dcdeaa8a48110e95b142b66 (patch) | |
tree | 971dcfcf56ead21ef19b6576205e99babfe54c8d /Objects | |
parent | 2e827bfdfea7b940517f90af78c986aec9159d2c (diff) | |
download | cpython-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 'Objects')
-rw-r--r-- | Objects/dictobject.c | 4 | ||||
-rw-r--r-- | Objects/setobject.c | 16 |
2 files changed, 19 insertions, 1 deletions
diff --git a/Objects/dictobject.c b/Objects/dictobject.c index eaa490e..165221e 100644 --- a/Objects/dictobject.c +++ b/Objects/dictobject.c @@ -1528,6 +1528,10 @@ PyDict_Merge(PyObject *a, PyObject *b, int override) static PyObject * dict_copy(register PyDictObject *mp) { + if (Py_Py3kWarningFlag && + PyErr_Warn(PyExc_DeprecationWarning, + "dict.copy() not supported in 3.x") < 0) + return NULL; return PyDict_Copy((PyObject*)mp); } diff --git a/Objects/setobject.c b/Objects/setobject.c index cc2c2ee..3869b3b 100644 --- a/Objects/setobject.c +++ b/Objects/setobject.c @@ -1131,8 +1131,22 @@ set_copy(PySetObject *so) } static PyObject * +set_copy_method(PySetObject *so) +{ + if (Py_Py3kWarningFlag && + PyErr_Warn(PyExc_DeprecationWarning, + "set.copy() not supported in 3.x") < 0) + return NULL; + return make_new_set(Py_TYPE(so), (PyObject *)so); +} + +static PyObject * frozenset_copy(PySetObject *so) { + if (Py_Py3kWarningFlag && + PyErr_Warn(PyExc_DeprecationWarning, + "frozenset.copy() not supported in 3.x") < 0) + return NULL; if (PyFrozenSet_CheckExact(so)) { Py_INCREF(so); return (PyObject *)so; @@ -1911,7 +1925,7 @@ static PyMethodDef set_methods[] = { clear_doc}, {"__contains__",(PyCFunction)set_direct_contains, METH_O | METH_COEXIST, contains_doc}, - {"copy", (PyCFunction)set_copy, METH_NOARGS, + {"copy", (PyCFunction)set_copy_method, METH_NOARGS, copy_doc}, {"discard", (PyCFunction)set_discard, METH_O, discard_doc}, |