changeset af77a8c0977c in tryton:6.2
details: https://hg.tryton.org/tryton?cmd=changeset&node=af77a8c0977c
description:
        Do not expand boolean PYSON when using __and__ and __or__

        It is not expected that the left operand is modified by such operations.

        issue11836
        review418551003
        (grafted from e695ee784608672c3fa251e473bd70cd12ea4ed5)
diffstat:

 tryton/pyson.py |  6 ++----
 1 files changed, 2 insertions(+), 4 deletions(-)

diffs (23 lines):

diff -r 8ff8b8e51e25 -r af77a8c0977c tryton/pyson.py
--- a/tryton/pyson.py   Sat Nov 05 17:11:45 2022 +0100
+++ b/tryton/pyson.py   Sat Nov 05 09:51:17 2022 +0100
@@ -31,8 +31,7 @@
             other = Bool(other)
         if (isinstance(self, And)
                 and not isinstance(self, Or)):
-            self._statements.append(other)
-            return self
+            return And(*self._statements, other)
         if self.types() != {bool}:
             return And(Bool(self), other)
         else:
@@ -45,8 +44,7 @@
                 and other.types() != {bool}):
             other = Bool(other)
         if isinstance(self, Or):
-            self._statements.append(other)
-            return self
+            return Or(*self._statements, other)
         if self.types() != {bool}:
             return Or(Bool(self), other)
         else:

Reply via email to