eric6/Debugger/VariablesViewer.py

changeset 8434
a105f31ba10f
parent 8240
93b8a353c4bf
child 8450
be7369a19dc9
child 8472
52e96cd0730d
--- a/eric6/Debugger/VariablesViewer.py	Wed Jun 16 19:06:47 2021 +0200
+++ b/eric6/Debugger/VariablesViewer.py	Sat Jun 19 16:22:11 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