Obviously this is not true for Python 2, so handle via the preprocessor.
Signed-off-by: Andy Grover <agrover(a)redhat.com>
---
python-ethtool/etherinfo_obj.c | 8 ++++++++
python-ethtool/netlink-address.c | 8 ++++++++
2 files changed, 16 insertions(+)
diff --git a/python-ethtool/etherinfo_obj.c b/python-ethtool/etherinfo_obj.c
index 7aefaa8..bf55e12 100644
--- a/python-ethtool/etherinfo_obj.c
+++ b/python-ethtool/etherinfo_obj.c
@@ -139,6 +139,14 @@ PyObject *_ethtool_etherinfo_str(PyEtherInfo *self)
}
}
+#if PY_MAJOR_VERSION >= 3
+ {
+ PyObject *bytestr = ret;
+ ret = PyUnicode_FromString(PyBytes_AsString(bytestr));
+ Py_DECREF(bytestr);
+ }
+#endif
+
return ret;
}
diff --git a/python-ethtool/netlink-address.c b/python-ethtool/netlink-address.c
index 2febc54..a2f37d1 100644
--- a/python-ethtool/netlink-address.c
+++ b/python-ethtool/netlink-address.c
@@ -156,6 +156,14 @@ netlink_ip_address_repr(PyNetlinkIPaddress *obj)
PyBytes_ConcatAndDel(&result, PyBytes_FromString(")"));
+#if PY_MAJOR_VERSION >= 3
+ {
+ PyObject *bytestr = result;
+ result = PyUnicode_FromString(PyBytes_AsString(result));
+ Py_DECREF(bytestr);
+ }
+#endif
+
return result;
}
--
1.9.3