RPM header data is in binary format; use the PyBytes_ API for it,
rather than PyString (which went away in Python 3)

On Python 2.6, these are macro aliases for the PyString_ API
On Python 3, these are references to the bytesobject.h class
---
 python/header-py.c |    6 +++---
 python/rpmts-py.c  |    4 ++--
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/python/header-py.c b/python/header-py.c
index cd3fe5e..98cd753 100644
--- a/python/header-py.c
+++ b/python/header-py.c
@@ -172,7 +172,7 @@ static PyObject * hdrUnload(hdrObject * s, PyObject * args, 
PyObject *keywords)
        return NULL;
     }
 
-    rc = PyString_FromStringAndSize(buf, len);
+    rc = PyBytes_FromStringAndSize(buf, len);
     buf = _free(buf);
 
     return rc;
@@ -371,8 +371,8 @@ static PyObject *hdr_new(PyTypeObject *subtype, PyObject 
*args, PyObject *kwds)
        h = headerNew();
     } else if (hdrObject_Check(obj)) {
        h = headerCopy(((hdrObject*) obj)->h);
-    } else if (PyString_Check(obj)) {
-       h = headerCopyLoad(PyString_AsString(obj));
+    } else if (PyBytes_Check(obj)) {
+       h = headerCopyLoad(PyBytes_AsString(obj));
     } else if (rpmFdFromPyObject(obj, &fd)) {
        Py_BEGIN_ALLOW_THREADS;
        h = headerRead(fd, HEADER_MAGIC_YES);
diff --git a/python/rpmts-py.c b/python/rpmts-py.c
index 8c0fe36..a0f4631 100644
--- a/python/rpmts-py.c
+++ b/python/rpmts-py.c
@@ -370,8 +370,8 @@ rpmts_HdrCheck(rpmtsObject * s, PyObject *obj)
     if (!PyArg_Parse(obj, "S:HdrCheck", &blob))
        return NULL;
 
-    uh = PyString_AsString(blob);
-    uc = PyString_Size(blob);
+    uh = PyBytes_AsString(blob);
+    uc = PyBytes_Size(blob);
 
     Py_BEGIN_ALLOW_THREADS;
     rpmrc = headerCheck(s->ts, uh, uc, &msg);
-- 
1.6.2.5

_______________________________________________
Rpm-maint mailing list
[email protected]
http://lists.rpm.org/mailman/listinfo/rpm-maint

Reply via email to