diff options
author | Panu Matilainen <pmatilai@redhat.com> | 2009-09-23 12:05:02 +0300 |
---|---|---|
committer | Panu Matilainen <pmatilai@redhat.com> | 2009-09-23 12:05:02 +0300 |
commit | ac219c129d04952fbd205c536533723d582d1ad2 (patch) | |
tree | d1bdfa7e8653547a8634cec0507516cb97b3c005 /python/rpmfd-py.c | |
parent | e72a51d081b192cbc35af47f8281e939370f8b55 (diff) | |
download | librpm-tizen-ac219c129d04952fbd205c536533723d582d1ad2.tar.gz librpm-tizen-ac219c129d04952fbd205c536533723d582d1ad2.tar.bz2 librpm-tizen-ac219c129d04952fbd205c536533723d582d1ad2.zip |
Turn rpmFdFromPyObject() into an object converter interface
- permits direct validation and conversion from arg parsing
Diffstat (limited to 'python/rpmfd-py.c')
-rw-r--r-- | python/rpmfd-py.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/python/rpmfd-py.c b/python/rpmfd-py.c index 2deb06793..868c293da 100644 --- a/python/rpmfd-py.c +++ b/python/rpmfd-py.c @@ -2,7 +2,7 @@ #include "rpmsystem-py.h" #include "rpmfd-py.h" -FD_t rpmFdFromPyObject(PyObject *obj) +int rpmFdFromPyObject(PyObject *obj, FD_t *fdp) { FD_t fd = NULL; @@ -13,10 +13,13 @@ FD_t rpmFdFromPyObject(PyObject *obj) fd = fdDup(fileno(fp)); } else { PyErr_SetString(PyExc_TypeError, "integer or file object expected"); - return NULL; + return 0; } if (fd == NULL || Ferror(fd)) { PyErr_SetFromErrno(PyExc_IOError); + Fclose(fd); + return 0; } - return fd; + *fdp = fd; + return 1; } |