mirror of
https://github.com/python/cpython.git
synced 2025-08-01 07:33:08 +00:00
Add -3 warnings that set.copy(), dict.copy(), and defaultdict.copy() will go away in Py3.x
This commit is contained in:
parent
2e827bfdfe
commit
17a74c395e
3 changed files with 31 additions and 3 deletions
|
@ -1130,9 +1130,23 @@ set_copy(PySetObject *so)
|
|||
return make_new_set(Py_TYPE(so), (PyObject *)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},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue