diff --git a/mongoengine/fields.py b/mongoengine/fields.py index a4640dda..b4dd456f 100644 --- a/mongoengine/fields.py +++ b/mongoengine/fields.py @@ -838,11 +838,10 @@ class BinaryField(BaseField): return Binary(value) def to_python(self, value): - # Returns str not unicode as this is binary data - return str(value) + return "%s" % value def validate(self, value): - if not isinstance(value, str): + if not isinstance(value, basestring): self.error('BinaryField only accepts string values') if self.max_bytes is not None and len(value) > self.max_bytes: @@ -1014,7 +1013,7 @@ class FileField(BaseField): def __set__(self, instance, value): key = self.name - if (hasattr(value, 'read') and not isinstance(value, GridFSProxy)) or isinstance(value, str): + if (hasattr(value, 'read') and not isinstance(value, GridFSProxy)) or isinstance(value, basestring): # using "FileField() = file/string" notation grid_file = instance._data.get(self.name) # If a file already exists, delete it diff --git a/mongoengine/queryset.py b/mongoengine/queryset.py index d06e3af1..64f9441a 100644 --- a/mongoengine/queryset.py +++ b/mongoengine/queryset.py @@ -702,7 +702,7 @@ class QuerySet(object): cleaned_fields = [] for field in fields: append_field = True - if isinstance(field, str): + if isinstance(field, basestring): parts.append(field) append_field = False else: diff --git a/setup.cfg b/setup.cfg index 6c5b9bae..51a18682 100644 --- a/setup.cfg +++ b/setup.cfg @@ -4,10 +4,10 @@ test = nosetests [nosetests] verbosity = 2 detailed-errors = 1 -with-coverage = 1 -cover-erase = 1 -cover-html = 1 -cover-html-dir = ../htmlcov -cover-package = mongoengine +#with-coverage = 1 +#cover-erase = 1 +#cover-html = 1 +#cover-html-dir = ../htmlcov +#cover-package = mongoengine where = tests #tests = test_bugfix.py