diff --git a/mongoengine/base/document.py b/mongoengine/base/document.py index b3b6c974..66217921 100644 --- a/mongoengine/base/document.py +++ b/mongoengine/base/document.py @@ -1,6 +1,5 @@ import copy import numbers -from collections import Hashable from functools import partial from bson import ObjectId, json_util @@ -19,6 +18,7 @@ from mongoengine.base.fields import ComplexBaseField from mongoengine.common import _import_class from mongoengine.errors import (FieldDoesNotExist, InvalidDocumentError, LookUpError, OperationError, ValidationError) +from mongoengine.python_support import Hashable __all__ = ('BaseDocument', 'NON_FIELD_ERRORS') diff --git a/mongoengine/python_support.py b/mongoengine/python_support.py index e884b4ea..7e8e108f 100644 --- a/mongoengine/python_support.py +++ b/mongoengine/python_support.py @@ -19,3 +19,10 @@ if not six.PY3: pass else: StringIO = cStringIO.StringIO + + +if six.PY3: + from collections.abc import Hashable +else: + # raises DeprecationWarnings in Python >=3.7 + from collections import Hashable