mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
Use bytes instead of str where appropriate
Under Python 2, "str" and "bytes" are synonyms. Reviewed-By: Petr Viktorin <pviktori@redhat.com>
This commit is contained in:
@@ -1333,7 +1333,7 @@ class Bytes(Data):
|
||||
Also see the `Str` parameter.
|
||||
"""
|
||||
|
||||
type = str
|
||||
type = bytes
|
||||
type_error = _('must be binary data')
|
||||
|
||||
def __init__(self, name, *rules, **kw):
|
||||
@@ -1348,7 +1348,7 @@ class Bytes(Data):
|
||||
"""
|
||||
Check minlength constraint.
|
||||
"""
|
||||
assert type(value) is str
|
||||
assert type(value) is bytes
|
||||
if len(value) < self.minlength:
|
||||
return _('must be at least %(minlength)d bytes') % dict(
|
||||
minlength=self.minlength,
|
||||
@@ -1358,7 +1358,7 @@ class Bytes(Data):
|
||||
"""
|
||||
Check maxlength constraint.
|
||||
"""
|
||||
assert type(value) is str
|
||||
assert type(value) is bytes
|
||||
if len(value) > self.maxlength:
|
||||
return _('can be at most %(maxlength)d bytes') % dict(
|
||||
maxlength=self.maxlength,
|
||||
@@ -1368,7 +1368,7 @@ class Bytes(Data):
|
||||
"""
|
||||
Check length constraint.
|
||||
"""
|
||||
assert type(value) is str
|
||||
assert type(value) is bytes
|
||||
if len(value) != self.length:
|
||||
return _('must be exactly %(length)d bytes') % dict(
|
||||
length=self.length,
|
||||
|
||||
Reference in New Issue
Block a user