summaryrefslogtreecommitdiffstats
path: root/python-ethtool/etherinfo_obj.c
diff options
context:
space:
mode:
authorDavid Sommerseth <davids@redhat.com>2013-12-16 12:17:03 +0100
committerDavid Sommerseth <davids@redhat.com>2013-12-16 12:23:43 +0100
commita05f17ca5737d03b127dd599363f009d5c6c8d48 (patch)
treecb5213c2fd9aea198bf8b0be8f414b54cdfc99e9 /python-ethtool/etherinfo_obj.c
parent3236cbdb03ed84271aeacc932760752a733204d4 (diff)
downloadpython-ethtool-a05f17ca5737d03b127dd599363f009d5c6c8d48.tar.gz
python-ethtool-a05f17ca5737d03b127dd599363f009d5c6c8d48.tar.xz
python-ethtool-a05f17ca5737d03b127dd599363f009d5c6c8d48.zip
Make the internal MAC address a Python string object
Signed-off-by: David Sommerseth <davids@redhat.com>
Diffstat (limited to 'python-ethtool/etherinfo_obj.c')
-rw-r--r--python-ethtool/etherinfo_obj.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/python-ethtool/etherinfo_obj.c b/python-ethtool/etherinfo_obj.c
index a251b56..6acc571 100644
--- a/python-ethtool/etherinfo_obj.c
+++ b/python-ethtool/etherinfo_obj.c
@@ -148,7 +148,8 @@ PyObject *_ethtool_etherinfo_getter(etherinfo_py *self, PyObject *attr_o)
return RETURN_STRING(self->data->ethinfo->device);
} else if( strcmp(attr, "mac_address") == 0 ) {
get_etherinfo(self->data, NLQRY_LINK);
- return RETURN_STRING(self->data->ethinfo->hwaddress);
+ Py_INCREF(self->data->ethinfo->hwaddress);
+ return self->data->ethinfo->hwaddress;
} else if( strcmp(attr, "ipv4_address") == 0 ) {
get_etherinfo(self->data, NLQRY_ADDR);
/* For compatiblity with old approach, return last IPv4 address: */
@@ -220,9 +221,9 @@ PyObject *_ethtool_etherinfo_str(etherinfo_py *self)
ret = PyString_FromFormat("Device %s:\n", self->data->ethinfo->device);
if( self->data->ethinfo->hwaddress ) {
- PyObject *tmp = PyString_FromFormat("\tMAC address: %s\n", self->data->ethinfo->hwaddress);
- PyString_Concat(&ret, tmp);
- Py_DECREF(tmp);
+ PyString_ConcatAndDel(&ret, PyString_FromString("\tMAC address: "));
+ PyString_Concat(&ret, self->data->ethinfo->hwaddress);
+ PyString_ConcatAndDel(&ret, PyString_FromString("\n"));
}
if( self->data->ethinfo->ipv4_addresses ) {