changeset e875094bb814 in proteus:6.6
details: https://hg.tryton.org/proteus?cmd=changeset&node=e875094bb814
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 393ef20df4b30ead8ef189e99cf03976abe0be08)
diffstat:

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

diffs (23 lines):

diff -r 2c7b82d4b941 -r e875094bb814 proteus/pyson.py
--- a/proteus/pyson.py  Mon Oct 31 16:38:32 2022 +0100
+++ b/proteus/pyson.py  Sat Nov 05 09:51:17 2022 +0100
@@ -32,8 +32,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:
@@ -46,8 +45,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