diff options
author | Guido van Rossum <guido@python.org> | 2006-08-18 22:13:04 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2006-08-18 22:13:04 (GMT) |
commit | e2b70bcf7401477936fba99a8bf4a1f759ecc8a3 (patch) | |
tree | 4c9b65b7fd8c26a3d2f1b64ecd6b4c72a756b4b2 /Objects | |
parent | d2dbecb4ae9177e2e87adcb047147c6bcbf28cc1 (diff) | |
download | cpython-e2b70bcf7401477936fba99a8bf4a1f759ecc8a3.zip cpython-e2b70bcf7401477936fba99a8bf4a1f759ecc8a3.tar.gz cpython-e2b70bcf7401477936fba99a8bf4a1f759ecc8a3.tar.bz2 |
Get rid of dict.has_key(). Boy this has a lot of repercussions!
Not all code has been fixed yet; this is just a checkpoint...
The C API still has PyDict_HasKey() and _HasKeyString(); not sure
if I want to change those just yet.
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/descrobject.c | 13 | ||||
-rw-r--r-- | Objects/dictobject.c | 9 | ||||
-rw-r--r-- | Objects/typeobject.c | 1 |
3 files changed, 3 insertions, 20 deletions
diff --git a/Objects/descrobject.c b/Objects/descrobject.c index 914b6d3..d6b789d 100644 --- a/Objects/descrobject.c +++ b/Objects/descrobject.c @@ -701,15 +701,6 @@ static PySequenceMethods proxy_as_sequence = { }; static PyObject * -proxy_has_key(proxyobject *pp, PyObject *key) -{ - int res = PyDict_Contains(pp->dict, key); - if (res < 0) - return NULL; - return PyBool_FromLong(res); -} - -static PyObject * proxy_get(proxyobject *pp, PyObject *args) { PyObject *key, *def = Py_None; @@ -761,10 +752,8 @@ proxy_copy(proxyobject *pp) } static PyMethodDef proxy_methods[] = { - {"has_key", (PyCFunction)proxy_has_key, METH_O, - PyDoc_STR("D.has_key(k) -> True if D has a key k, else False")}, {"get", (PyCFunction)proxy_get, METH_VARARGS, - PyDoc_STR("D.get(k[,d]) -> D[k] if D.has_key(k), else d." + PyDoc_STR("D.get(k[,d]) -> D[k] if k in D, else d." " d defaults to None.")}, {"keys", (PyCFunction)proxy_keys, METH_NOARGS, PyDoc_STR("D.keys() -> list of D's keys")}, diff --git a/Objects/dictobject.c b/Objects/dictobject.c index f4c185d..b3fdbf1 100644 --- a/Objects/dictobject.c +++ b/Objects/dictobject.c @@ -1621,7 +1621,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; @@ -1856,9 +1856,6 @@ dict_iteritems(dictobject *dict) } -PyDoc_STRVAR(has_key__doc__, -"D.has_key(k) -> True if D has a key k, else False"); - PyDoc_STRVAR(contains__doc__, "D.__contains__(k) -> True if D has a key k, else False"); @@ -1911,12 +1908,10 @@ 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__}, - {"has_key", (PyCFunction)dict_has_key, METH_O, - has_key__doc__}, {"get", (PyCFunction)dict_get, METH_VARARGS, get__doc__}, {"setdefault", (PyCFunction)dict_setdefault, METH_VARARGS, diff --git a/Objects/typeobject.c b/Objects/typeobject.c index 7b15925..02d45bd 100644 --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -4432,7 +4432,6 @@ slot_tp_hash(PyObject *self) } if (func == NULL) { - PyErr_Clear(); PyErr_Format(PyExc_TypeError, "unhashable type: '%.200s'", self->ob_type->tp_name); return -1; |