diff options
author | Panu Matilainen <pmatilai@redhat.com> | 2009-11-21 11:31:50 +0200 |
---|---|---|
committer | Panu Matilainen <pmatilai@redhat.com> | 2009-11-21 11:31:50 +0200 |
commit | 1e2f382ff7912f743d4c18d85386506048d0d29d (patch) | |
tree | 192cad38c6c55bfda0dbfd5ada5d480436022162 /python/header-py.c | |
parent | 6711bcc6b948f8f60373af42e232e160c8cb89ed (diff) | |
download | librpm-tizen-1e2f382ff7912f743d4c18d85386506048d0d29d.tar.gz librpm-tizen-1e2f382ff7912f743d4c18d85386506048d0d29d.tar.bz2 librpm-tizen-1e2f382ff7912f743d4c18d85386506048d0d29d.zip |
Remove hdr.has_key() method, support 'key in h' style instead
- Python 3 removed has_key() from dictionaries, as the 'in' way is the
way of the future support that from the start (has_key() is not in
any released rpm version so its safe to remove)
Diffstat (limited to 'python/header-py.c')
-rw-r--r-- | python/header-py.c | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/python/header-py.c b/python/header-py.c index 96f49ee6f..57eb74bc2 100644 --- a/python/header-py.c +++ b/python/header-py.c @@ -244,12 +244,12 @@ static PyObject *hdrIsSource(hdrObject *s) return PyBool_FromLong(headerIsSource(s->h)); } -static PyObject *hdrHasKey(hdrObject *s, PyObject *pytag) +static int hdrContains(hdrObject *s, PyObject *pytag) { rpmTag tag; if (!tagNumFromPyObject(pytag, &tag)) return NULL; - return PyBool_FromLong(headerIsEntry(s->h, tag)); + return headerIsEntry(s->h, tag); } static PyObject *hdrConvert(hdrObject *self, PyObject *args, PyObject *kwds) @@ -326,8 +326,6 @@ static struct PyMethodDef hdr_methods[] = { NULL }, {"format", (PyCFunction) hdrFormat, METH_VARARGS|METH_KEYWORDS, NULL }, - {"has_key", (PyCFunction) hdrHasKey, METH_O, - NULL }, {"sprintf", (PyCFunction) hdrFormat, METH_VARARGS|METH_KEYWORDS, NULL }, {"isSource", (PyCFunction)hdrIsSource, METH_NOARGS, @@ -505,6 +503,19 @@ static PyMappingMethods hdr_as_mapping = { (objobjargproc)hdr_ass_subscript,/* mp_ass_subscript */ }; +static PySequenceMethods hdr_as_sequence = { + 0, /* sq_length */ + 0, /* sq_concat */ + 0, /* sq_repeat */ + 0, /* sq_item */ + 0, /* sq_slice */ + 0, /* sq_ass_item */ + 0, /* sq_ass_slice */ + (objobjproc)hdrContains, /* sq_contains */ + 0, /* sq_inplace_concat */ + 0, /* sq_inplace_repeat */ +}; + static char hdr_doc[] = ""; @@ -520,7 +531,7 @@ PyTypeObject hdr_Type = { 0, /* tp_compare */ 0, /* tp_repr */ 0, /* tp_as_number */ - 0, /* tp_as_sequence */ + &hdr_as_sequence, /* tp_as_sequence */ &hdr_as_mapping, /* tp_as_mapping */ hdr_hash, /* tp_hash */ 0, /* tp_call */ |