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:
Jan Cholasta
2015-09-11 14:02:13 +02:00
parent 23507e6124
commit ba5201979d
6 changed files with 33 additions and 33 deletions

View File

@@ -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,