summaryrefslogtreecommitdiffstats
path: root/Objects/dictobject.c
diff options
context:
space:
mode:
authorNeal Norwitz <nnorwitz@gmail.com>2007-05-23 06:35:32 (GMT)
committerNeal Norwitz <nnorwitz@gmail.com>2007-05-23 06:35:32 (GMT)
commit8b2bfbc198c1fe0dcdfd42cc4683879cd712ccfd (patch)
tree9f3e2eed06cc877197eaadc398fb0bd12f5b9db3 /Objects/dictobject.c
parent5f2ba9f2b1d5bd7ce9a6388dc58624403ca54547 (diff)
downloadcpython-8b2bfbc198c1fe0dcdfd42cc4683879cd712ccfd.zip
cpython-8b2bfbc198c1fe0dcdfd42cc4683879cd712ccfd.tar.gz
cpython-8b2bfbc198c1fe0dcdfd42cc4683879cd712ccfd.tar.bz2
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.
Diffstat (limited to 'Objects/dictobject.c')
-rw-r--r--Objects/dictobject.c14
1 files changed, 12 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__},