From 6e8196d475953f88bd70207e81234bc07e1526d0 Mon Sep 17 00:00:00 2001 From: Filip Kucharczyk Date: Thu, 5 Dec 2019 01:31:37 +0100 Subject: [PATCH] Python 2.x compatibility --- mongoengine/queryset/visitor.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/mongoengine/queryset/visitor.py b/mongoengine/queryset/visitor.py index 8038d23f..7faed897 100644 --- a/mongoengine/queryset/visitor.py +++ b/mongoengine/queryset/visitor.py @@ -143,6 +143,8 @@ class QCombination(QNode): def __bool__(self): return bool(self.children) + __nonzero__ = __bool__ # For Py2 support + def accept(self, visitor): for i in range(len(self.children)): if isinstance(self.children[i], QNode): @@ -178,6 +180,8 @@ class Q(QNode): def __bool__(self): return bool(self.query) + __nonzero__ = __bool__ # For Py2 support + def __eq__(self, other): return self.__class__ == other.__class__ and self.query == other.query