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

        issue11278
        review382031002
diffstat:

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

diffs (23 lines):

diff -r f801a89c84e7 -r a6e66a14f5c8 proteus/pyson.py
--- a/proteus/pyson.py  Tue Mar 01 19:07:56 2022 +0100
+++ b/proteus/pyson.py  Sun Mar 06 13:46:49 2022 +0100
@@ -495,11 +495,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