diff options
author | Neal Norwitz <nnorwitz@gmail.com> | 2007-05-23 06:35:32 (GMT) |
---|---|---|
committer | Neal Norwitz <nnorwitz@gmail.com> | 2007-05-23 06:35:32 (GMT) |
commit | 8b2bfbc198c1fe0dcdfd42cc4683879cd712ccfd (patch) | |
tree | 9f3e2eed06cc877197eaadc398fb0bd12f5b9db3 /Objects | |
parent | 5f2ba9f2b1d5bd7ce9a6388dc58624403ca54547 (diff) | |
download | cpython-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')
-rw-r--r-- | Objects/dictobject.c | 14 | ||||
-rw-r--r-- | Objects/object.c | 1 |
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. |