Merge lp:~ivoks/charm-helpers/no_ip_valueerror into lp:charm-helpers

Proposed by Ante Karamatić
Status: Merged
Merged at revision: 632
Proposed branch: lp:~ivoks/charm-helpers/no_ip_valueerror
Merge into: lp:charm-helpers
Diff against target: 10 lines (+1/-1)
1 file modified
charmhelpers/contrib/network/ip.py (+1/-1)
To merge this branch: bzr merge lp:~ivoks/charm-helpers/no_ip_valueerror
Reviewer Review Type Date Requested Status
Liam Young (community) Approve
Review via email: mp+306445@code.launchpad.net

Description of the change

Since some values raise ValueError instead of netaddr.core.AddrFormatError exception, this change allows is_ip() to catch both exceptions.

To post a comment you must log in.
Revision history for this message
Liam Young (gnuoy) wrote :

LGTM, thanks

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'charmhelpers/contrib/network/ip.py'
--- charmhelpers/contrib/network/ip.py 2016-07-18 15:59:52 +0000
+++ charmhelpers/contrib/network/ip.py 2016-09-22 11:56:06 +0000
@@ -406,7 +406,7 @@
406 # Test to see if already an IPv4/IPv6 address406 # Test to see if already an IPv4/IPv6 address
407 address = netaddr.IPAddress(address)407 address = netaddr.IPAddress(address)
408 return True408 return True
409 except netaddr.AddrFormatError:409 except (netaddr.AddrFormatError, ValueError):
410 return False410 return False
411411
412412

Subscribers

People subscribed via source and target branches