diff --git a/examples/python/domipaddrs.py b/examples/python/domipaddrs.py
index 679e0bf..8903673 100755
--- a/examples/python/domipaddrs.py
+++ b/examples/python/domipaddrs.py
@@ -39,11 +39,17 @@ if (ifaces == None):
 
 print " {0:10} {1:20} {2:12} {3}".format("Interface", "MAC address", "Protocol", "Address")
 
+def toIPAddrType(addrType):
+    if addrType == libvirt.VIR_IP_ADDR_TYPE_IPV4:
+        return "ipv4"
+    elif addrType == libvirt.VIR_IP_ADDR_TYPE_IPV6:
+        return "ipv6"
+
 for (name, val) in ifaces.iteritems():
     if val['ip_addrs']:
         for addr in val['ip_addrs']:
            print " {0:10} {1:19}".format(name, val['hwaddr']),
-           print " {0:12} {1}/{2} ".format(addr['type'], addr['addr'], addr['prefix']),
+           print " {0:12} {1}/{2} ".format(toIPAddrType(addr['type']), addr['addr'], addr['prefix']),
            print
     else:
         print " {0:10} {1:19}".format(name, val['hwaddr']),
diff --git a/python/libvirt-override.c b/python/libvirt-override.c
index 67e0cb8..f288587 100644
--- a/python/libvirt-override.c
+++ b/python/libvirt-override.c
@@ -4812,7 +4812,7 @@ libvirt_virDomainInterfaceAddresses(PyObject *self ATTRIBUTE_UNUSED,
         for (j = 0; j < iface->naddrs; j++) {
             virDomainIPAddressPtr ip_addr = &(iface->addrs[j]);
             PyObject *py_addr = PyDict_New();
-            const char *type = NULL;
+            int type = ip_addr->type;
 
             if (!py_addr) {
                 Py_DECREF(py_iface);
@@ -4820,21 +4820,12 @@ libvirt_virDomainInterfaceAddresses(PyObject *self ATTRIBUTE_UNUSED,
                 goto no_memory;
             }
 
-            switch (ip_addr->type) {
-            case VIR_IP_ADDR_TYPE_IPV4:
-                type = "ipv4";
-                break;
-            case VIR_IP_ADDR_TYPE_IPV6:
-                type = "ipv6";
-                break;
-            }
-
             PyDict_SetItem(py_addr, libvirt_constcharPtrWrap("addr"),
                            PyString_FromString(ip_addr->addr));
             PyDict_SetItem(py_addr, libvirt_constcharPtrWrap("prefix"),
                            libvirt_intWrap(ip_addr->prefix));
             PyDict_SetItem(py_addr, libvirt_constcharPtrWrap("type"),
-                           PyString_FromString(type));
+                           libvirt_intWrap(type));
 
             PyList_SetItem(py_ip_addrs, j, py_addr);
         }
