From 86527f0d45c033347880907cf7680230ecb9ecb9 Mon Sep 17 00:00:00 2001 From: Panu Matilainen Date: Wed, 23 Sep 2009 13:12:43 +0300 Subject: [PATCH] Oops, binary data can and should be presented as python strings --- python/rpmtd-py.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/python/rpmtd-py.c b/python/rpmtd-py.c index 77df8cd..cf8c92e 100644 --- a/python/rpmtd-py.c +++ b/python/rpmtd-py.c @@ -12,8 +12,6 @@ static PyObject * rpmtd_ItemAsPyobj(rpmtd td, rpmTagClass class) { PyObject *res = NULL; - char *str = NULL; - const char *errmsg = NULL; switch (class) { case RPM_STRING_CLASS: @@ -23,13 +21,7 @@ static PyObject * rpmtd_ItemAsPyobj(rpmtd td, rpmTagClass class) res = PyLong_FromLongLong(rpmtdGetNumber(td)); break; case RPM_BINARY_CLASS: - str = rpmtdFormat(td, RPMTD_FORMAT_STRING, &errmsg); - if (errmsg) { - PyErr_SetString(PyExc_ValueError, errmsg); - } else { - res = PyString_FromString(str); - } - free(str); + res = PyString_FromStringAndSize(td->data, td->count); break; default: PyErr_SetString(PyExc_KeyError, "unknown data type"); -- 2.7.4