Accept any file object in ts.hdrFromFdno()
authorPanu Matilainen <pmatilai@redhat.com>
Wed, 23 Sep 2009 08:10:38 +0000 (11:10 +0300)
committerPanu Matilainen <pmatilai@redhat.com>
Wed, 23 Sep 2009 08:10:38 +0000 (11:10 +0300)
python/rpmts-py.c

index 6d858ac..7824ba8 100644 (file)
@@ -8,6 +8,7 @@
 
 #include "header-py.h"
 #include "rpmds-py.h"  /* XXX for rpmdsNew */
+#include "rpmfd-py.h"
 #include "rpmfi-py.h"  /* XXX for rpmfiNew */
 #include "rpmmi-py.h"
 #include "rpmps-py.h"
@@ -454,17 +455,16 @@ static PyObject *
 rpmts_HdrFromFdno(rpmtsObject * s, PyObject * args, PyObject * kwds)
 {
     PyObject * result = NULL;
+    PyObject * fo = NULL;
     Header h;
     FD_t fd;
-    int fdno;
     rpmRC rpmrc;
     char * kwlist[] = {"fd", NULL};
 
-    if (!PyArg_ParseTupleAndKeywords(args, kwds, "i:HdrFromFdno", kwlist,
-           &fdno))
+    if (!PyArg_ParseTupleAndKeywords(args, kwds, "O:HdrFromFdno", kwlist, &fo))
        return NULL;
 
-    fd = fdDup(fdno);
+    if ((fd = rpmFdFromPyObject(fo)) == NULL) return NULL;
     rpmrc = rpmReadPackageFile(s->ts, fd, "rpmts_HdrFromFdno", &h);
     Fclose(fd);