From d4bc3a50bb6124a0000879f27d43e9685934d682 Mon Sep 17 00:00:00 2001 From: David Sommerseth Date: Fri, 20 Dec 2013 01:46:01 +0100 Subject: Make the device string a python object as well This will simplify to "pythonize" struct etherinfo further. Signed-off-by: David Sommerseth --- python-ethtool/etherinfo_obj.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'python-ethtool/etherinfo_obj.c') diff --git a/python-ethtool/etherinfo_obj.c b/python-ethtool/etherinfo_obj.c index 7885a48..07e4b58 100644 --- a/python-ethtool/etherinfo_obj.c +++ b/python-ethtool/etherinfo_obj.c @@ -138,7 +138,8 @@ PyObject *_ethtool_etherinfo_getter(etherinfo_py *self, PyObject *attr_o) if( strcmp(attr, "device") == 0 ) { if( self->ethinfo->device ) { - return PyString_FromString(self->ethinfo->device); + Py_INCREF(self->ethinfo->device); + return self->ethinfo->device; } else { return Py_INCREF(Py_None), Py_None; } @@ -215,7 +216,10 @@ PyObject *_ethtool_etherinfo_str(etherinfo_py *self) get_etherinfo_link(self); - ret = PyString_FromFormat("Device %s:\n", self->ethinfo->device); + ret = PyString_FromFormat("Device "); + PyString_Concat(&ret, self->ethinfo->device); + PyString_ConcatAndDel(&ret, PyString_FromString(":\n")); + if( self->ethinfo->hwaddress ) { PyString_ConcatAndDel(&ret, PyString_FromString("\tMAC address: ")); PyString_Concat(&ret, self->ethinfo->hwaddress); -- cgit