eric6/Debugger/VariablesViewer.py

branch
maintenance
changeset 8450
be7369a19dc9
parent 8273
698ae46f40a4
parent 8434
a105f31ba10f
child 8576
fe1957c69854
--- a/eric6/Debugger/VariablesViewer.py	Thu Jun 03 11:39:55 2021 +0200
+++ b/eric6/Debugger/VariablesViewer.py	Sat Jul 03 11:47:24 2021 +0200
@@ -196,16 +196,38 @@
             self.childCount = int(dvalue)
             dvalue = VariableItem.noOfItemsStr.format(dvalue)
             self.hasChildren = True
-            
+        
         elif dtype == "Shiboken.EnumType":
             self.hasChildren = True
-            
+        
         elif dtype == 'str':
             if VariableItem.rx_nonprintable.search(dvalue) is None:
                 with contextlib.suppress(Exception):
                     dvalue = ast.literal_eval(dvalue)
             dvalue = str(dvalue)
         
+        elif (
+            dvalue.startswith(("{", "(", "[")) and
+            dvalue.endswith(("}", ")", "]"))
+        ):
+            # it is most probably a dict, tuple or list derived class
+            value = ast.literal_eval(dvalue)
+            valueTypeStr = str(type(value))[8:-2]
+            if valueTypeStr in VariableItem.arrayTypes:
+                self.childCount = len(value)
+                self.hasChildren = True
+        
+        elif (
+            (dvalue.endswith("})") and "({" in dvalue) or
+            (dvalue.endswith("])") and "([" in dvalue)
+        ):
+            # that is probably a set derived class
+            value = ast.literal_eval(dvalue.split("(", 1)[1][:-1])
+            valueTypeStr = str(type(value))[8:-2]
+            if valueTypeStr in VariableItem.arrayTypes:
+                self.childCount = len(value)
+                self.hasChildren = True
+        
         self.value = dvalue
         
         if len(dvalue) > 2048:     # 2 kB

eric ide

mercurial