[Twisted-Python] IPv6 comparison handling
![](https://secure.gravatar.com/avatar/9b74e38cc24a1ca56707272717f736ec.jpg?s=120&d=mm&r=g)
Hello, In my UDP Twisted based library there is a problem with IPv6 addresses representation. Addresses are compared as simple strings, and it sometimes causes mismatches: "fe80::aaaa:bbff:fecc:dddd" should be equal to "fe80:0000:0000:0000:aaaa:bbff:fecc:dddd" I've noticed that Python 3 has nice new module "ipaddress" exactly for this kind of problems, and it has been backported to Python 2.7. Before I add it as a new dependency I wanted to ask if maybe Twisted has some other suggested solution for this problem? Best Regards Maciej Wasilak
![](https://secure.gravatar.com/avatar/e1554622707bedd9202884900430b838.jpg?s=120&d=mm&r=g)
You should probably use ipaddress. Twisted's facilities in this area are somewhat primitive, and should be improved; particularly, you _should_ be able to do: a = IPv6Address("UDP", "fe80::", 0) b = IPv6Address("UDP", "fe80::00:00", 0) a == b but right now that doesn't work. A patch that fixes it would be much appreciated though! -glyph
![](https://secure.gravatar.com/avatar/e1554622707bedd9202884900430b838.jpg?s=120&d=mm&r=g)
You should probably use ipaddress. Twisted's facilities in this area are somewhat primitive, and should be improved; particularly, you _should_ be able to do: a = IPv6Address("UDP", "fe80::", 0) b = IPv6Address("UDP", "fe80::00:00", 0) a == b but right now that doesn't work. A patch that fixes it would be much appreciated though! -glyph
participants (2)
-
Glyph
-
Maciej Wasilak