mirror of
https://github.com/python/cpython.git
synced 2025-08-02 16:13:13 +00:00
Add -3 option to the interpreter to warn about features that are
deprecated and will be changed/removed in Python 3.0. This patch is mostly from Anthony. I tweaked some format and added a little doc.
This commit is contained in:
parent
5f2ba9f2b1
commit
8b2bfbc198
7 changed files with 31 additions and 3 deletions
|
@ -1688,7 +1688,7 @@ dict_richcompare(PyObject *v, PyObject *w, int op)
|
|||
}
|
||||
|
||||
static PyObject *
|
||||
dict_has_key(register dictobject *mp, PyObject *key)
|
||||
dict_contains(register dictobject *mp, PyObject *key)
|
||||
{
|
||||
long hash;
|
||||
dictentry *ep;
|
||||
|
@ -1705,6 +1705,16 @@ dict_has_key(register dictobject *mp, PyObject *key)
|
|||
return PyBool_FromLong(ep->me_value != NULL);
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
dict_has_key(register dictobject *mp, PyObject *key)
|
||||
{
|
||||
if (Py_Py3kWarningFlag &&
|
||||
PyErr_Warn(PyExc_DeprecationWarning,
|
||||
"dict.has_key() not supported in 3.x") < 0)
|
||||
return NULL;
|
||||
return dict_contains(mp, key);
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
dict_get(register dictobject *mp, PyObject *args)
|
||||
{
|
||||
|
@ -1978,7 +1988,7 @@ PyDoc_STRVAR(iteritems__doc__,
|
|||
"D.iteritems() -> an iterator over the (key, value) items of D");
|
||||
|
||||
static PyMethodDef mapp_methods[] = {
|
||||
{"__contains__",(PyCFunction)dict_has_key, METH_O | METH_COEXIST,
|
||||
{"__contains__",(PyCFunction)dict_contains, METH_O | METH_COEXIST,
|
||||
contains__doc__},
|
||||
{"__getitem__", (PyCFunction)dict_subscript, METH_O | METH_COEXIST,
|
||||
getitem__doc__},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue