Oops, binary data can and should be presented as python strings
authorPanu Matilainen <pmatilai@redhat.com>
Wed, 23 Sep 2009 10:12:43 +0000 (13:12 +0300)
committerPanu Matilainen <pmatilai@redhat.com>
Wed, 23 Sep 2009 10:12:43 +0000 (13:12 +0300)
python/rpmtd-py.c

index 77df8cd..cf8c92e 100644 (file)
@@ -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");