BinaryField returns str not unicode

This commit is contained in:
Harry Marr
2010-04-17 21:24:06 +01:00
parent 3c7e8be2e7
commit edfda6ad5b
2 changed files with 4 additions and 3 deletions

View File

@@ -505,10 +505,11 @@ class BinaryField(BaseField):
return pymongo.binary.Binary(value)
def to_python(self, value):
return unicode(value)
# Returns str not unicode as this is binary data
return str(value)
def validate(self, value):
assert isinstance(value, str)
if self.max_bytes is not None and len(value) > self.max_bytes:
raise ValidationError('Binary value is too long')
raise ValidationError('Binary value is too long')