VariablesViewer: fixed an issue causing string like variables with values enclosed in '{}', '[]' or '()' not being shown dur to an exception (issue396). eric7

Sun, 18 Jul 2021 14:28:27 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sun, 18 Jul 2021 14:28:27 +0200
branch
eric7
changeset 8473
754a0ff2ceaa
parent 8471
e1f001ffdce4
child 8475
f1f7646e8e24

VariablesViewer: fixed an issue causing string like variables with values enclosed in '{}', '[]' or '()' not being shown dur to an exception (issue396).
(grafted from 52e96cd0730d2f2597e9eb1f30da011fa0b7ecd6)

eric7/Debugger/VariablesViewer.py file | annotate | diff | comparison | revisions
--- a/eric7/Debugger/VariablesViewer.py	Sun Jul 18 12:23:03 2021 +0200
+++ b/eric7/Debugger/VariablesViewer.py	Sun Jul 18 14:28:27 2021 +0200
@@ -211,22 +211,24 @@
             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
+            with contextlib.suppress(Exception):
+                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
+            with contextlib.suppress(Exception):
+                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
         

eric ide

mercurial