changeset 4dea783ce67b in proteus:6.2
details: https://hg.tryton.org/proteus?cmd=changeset&node=4dea783ce67b
description:
        Allow PYSON Expression as key for PYSON In with dict object

        issue11278
        review382031002
        (grafted from a6e66a14f5c83959772f67be8d1904f26e0eb5bc)
diffstat:

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

diffs (23 lines):

diff -r b2054b851e1b -r 4dea783ce67b proteus/pyson.py
--- a/proteus/pyson.py  Tue Mar 01 19:23:06 2022 +0100
+++ b/proteus/pyson.py  Sun Mar 06 13:46:49 2022 +0100
@@ -485,11 +485,17 @@
             assert obj.types().issubset({dict, list}), \
                 'obj must be a dict or a list'
             if obj.types() == {dict}:
-                assert isinstance(key, str), 'key must be a string'
+                if isinstance(key, PYSON):
+                    assert key.types() == {str}, 'key must be a string'
+                else:
+                    assert isinstance(key, str), 'key must be a string'
         else:
             assert isinstance(obj, (dict, list))
             if isinstance(obj, dict):
-                assert isinstance(key, str), 'key must be a string'
+                if isinstance(key, PYSON):
+                    assert key.types() == {str}, 'key must be a string'
+                else:
+                    assert isinstance(key, str), 'key must be a string'
         self._key = key
         self._obj = obj
 

Reply via email to