Support accessing header info in python by object attributes as well.
authorPanu Matilainen <pmatilai@redhat.com>
Tue, 28 Aug 2007 09:07:50 +0000 (12:07 +0300)
committerPanu Matilainen <pmatilai@redhat.com>
Tue, 28 Aug 2007 09:07:50 +0000 (12:07 +0300)
python/header-py.c

index e74077e..ff23316 100644 (file)
@@ -347,19 +347,6 @@ static struct PyMethodDef hdr_methods[] = {
     {NULL,             NULL}           /* sentinel */
 };
 
-static PyObject * hdr_getattro(PyObject * o, PyObject * n)
-       /*@*/
-{
-    return PyObject_GenericGetAttr(o, n);
-}
-
-static int hdr_setattro(PyObject * o, PyObject * n, PyObject * v)
-       /*@*/
-{
-    return PyObject_GenericSetAttr(o, n, v);
-}
-
-
 /** \ingroup py_c
  */
 static void hdr_dealloc(hdrObject * s)
@@ -542,6 +529,20 @@ static PyObject * hdr_subscript(hdrObject * s, PyObject * item)
     return o;
 }
 
+static PyObject * hdr_getattro(PyObject * o, PyObject * n)
+{
+    PyObject * res;
+    res = PyObject_GenericGetAttr(o, n);
+    if (res == NULL)
+       res = hdr_subscript(o, n);
+    return res;
+}
+
+static int hdr_setattro(PyObject * o, PyObject * n, PyObject * v)
+{
+    return PyObject_GenericSetAttr(o, n, v);
+}
+
 /** \ingroup py_c
  */
 /*@unchecked@*/ /*@observer@*/