diff options
author | Lynn Root <lroot@redhat.com> | 2012-11-08 10:06:35 -0500 |
---|---|---|
committer | Martin Kosek <mkosek@redhat.com> | 2012-12-11 10:52:06 +0100 |
commit | 173ee4d141958f198a706d65d4ee47c4a2ec31ed (patch) | |
tree | f03ad715dfa5f57ce676327f709831264d54612f /ipalib/parameters.py | |
parent | 585b91df3b1fab9c865e00f522950003709ea23d (diff) | |
download | freeipa-173ee4d141958f198a706d65d4ee47c4a2ec31ed.tar.gz freeipa-173ee4d141958f198a706d65d4ee47c4a2ec31ed.tar.xz freeipa-173ee4d141958f198a706d65d4ee47c4a2ec31ed.zip |
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
Diffstat (limited to 'ipalib/parameters.py')
-rw-r--r-- | ipalib/parameters.py | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/ipalib/parameters.py b/ipalib/parameters.py index b3a75f288..670e03605 100644 --- a/ipalib/parameters.py +++ b/ipalib/parameters.py @@ -879,10 +879,8 @@ class Param(ReadOnly): def _validate_scalar(self, value, index=None): if type(value) is not self.type: - raise ValidationError(name=self.name, - error='need a %r; got %r (a %r)' % ( - self.type, value, type(value) - ) + raise TypeError( + TYPE_ERROR % (self.name, self.type, value, type(value)) ) if index is not None and type(index) is not int: raise TypeError( @@ -1167,11 +1165,9 @@ class Int(Number): the exception that it allows both int and long types. The min/max rules handle size enforcement. """ - if type(value) not in (int, long): - raise ValidationError(name=self.name, - error='need a %r; got %r (a %r)' % ( - self.type, value, type(value) - ) + if type(value) not in (int, long): + raise TypeError( + TYPE_ERROR % (self.name, self.type, value, type(value)) ) if index is not None and type(index) is not int: raise TypeError( @@ -1553,7 +1549,7 @@ class IA5Str(Str): if ord(value[i]) > 127: raise ConversionError(name=self.get_param_name(), index=index, - error=_('The character \'%(char)r\' is not allowed.') % + error=_('The character %(char)r is not allowed.') % dict(char=value[i],) ) return super(IA5Str, self)._convert_scalar(value, index) |