Switch %r specifiers to '%s' in Public errors

This switch drops the preceding 'u' from strings within Public error messages.

This patch also addresses the related unfriendly 'u' from re-raising errors from netaddr.IPAddress by passing a bytestring through the function.

Also switched ValidationError to TypeError in validate_scalar per jcholast@redhat.com.

Ticket: https://fedorahosted.org/freeipa/ticket/3121
Ticket: https://fedorahosted.org/freeipa/ticket/2588
This commit is contained in:
Lynn Root
2012-11-08 10:06:35 -05:00
committed by Martin Kosek
parent 585b91df3b
commit 173ee4d141
8 changed files with 43 additions and 47 deletions

View File

@@ -103,7 +103,7 @@ class CheckedIPAddress(netaddr.IPAddress):
else:
try:
try:
addr = netaddr.IPAddress(addr, flags=self.netaddr_ip_flags)
addr = netaddr.IPAddress(str(addr), flags=self.netaddr_ip_flags)
except netaddr.AddrFormatError:
# netaddr.IPAddress doesn't handle zone indices in textual
# IPv6 addresses. Try removing zone index and parse the
@@ -113,11 +113,11 @@ class CheckedIPAddress(netaddr.IPAddress):
addr, sep, foo = addr.partition('%')
if sep != '%':
raise
addr = netaddr.IPAddress(addr, flags=self.netaddr_ip_flags)
addr = netaddr.IPAddress(str(addr), flags=self.netaddr_ip_flags)
if addr.version != 6:
raise
except ValueError:
net = netaddr.IPNetwork(addr, flags=self.netaddr_ip_flags)
net = netaddr.IPNetwork(str(addr), flags=self.netaddr_ip_flags)
if not parse_netmask:
raise ValueError("netmask and prefix length not allowed here")
addr = net.ip