summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
Diffstat (limited to 'Objects')
-rw-r--r--Objects/dictobject.c14
-rw-r--r--Objects/object.c1
2 files changed, 13 insertions, 2 deletions
diff --git a/Objects/dictobject.c b/Objects/dictobject.c
index 7d6ff61..daf64e0 100644
--- a/Objects/dictobject.c
+++ b/Objects/dictobject.c
@@ -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;
@@ -1706,6 +1706,16 @@ dict_has_key(register dictobject *mp, PyObject *key)
}
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)
{
PyObject *key;
@@ -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__},
diff --git a/Objects/object.c b/Objects/object.c
index 9e25467..8de6723 100644
--- a/Objects/object.c
+++ b/Objects/object.c
@@ -29,6 +29,7 @@ _Py_GetRefTotal(void)
#endif /* Py_REF_DEBUG */
int Py_DivisionWarningFlag;
+int Py_Py3kWarningFlag;
/* Object allocation routines used by NEWOBJ and NEWVAROBJ macros.
These are used by the individual routines for object creation.