[Rpm-maint] [PATCH 13/15] str() returns a PyUnicode for Python 3

David Malcolm dmalcolm at redhat.com
Thu Oct 15 19:15:07 UTC 2009


---
 python/rpmtd-py.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/python/rpmtd-py.c b/python/rpmtd-py.c
index 1ee0846..aa5be4f 100644
--- a/python/rpmtd-py.c
+++ b/python/rpmtd-py.c
@@ -66,7 +66,11 @@ static PyObject *rpmtd_str(rpmtdObject *s)
     PyObject *res = NULL;
     char *str = rpmtdFormat(&(s->td), RPMTD_FORMAT_STRING, NULL);
     if (str) {
+#if PY_MAJOR_VERSION >= 3
+        res = PyUnicode_FromString(str);
+#else
         res = PyString_FromString(str);
+#endif
 	free(str);
     } else {
 	res = PyObject_Repr((PyObject *)s);
-- 
1.6.2.5



More information about the Rpm-maint mailing list