Fixed an issue that could cause the debugger backends to crash, if a class redefined __repr__. 5_3_x

Wed, 13 Mar 2013 18:35:24 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Wed, 13 Mar 2013 18:35:24 +0100
branch
5_3_x
changeset 2487
75ee609c3241
parent 2485
05b056d48e28
child 2489
4f6cc64ca547

Fixed an issue that could cause the debugger backends to crash, if a class redefined __repr__.
(grafted from e16c9ced6ae5d9a3a6a6260d139ca35a212d65f8)

DebugClients/Python/DebugClientBase.py file | annotate | diff | comparison | revisions
DebugClients/Python3/DebugBase.py file | annotate | diff | comparison | revisions
DebugClients/Python3/DebugClientBase.py file | annotate | diff | comparison | revisions
--- a/DebugClients/Python/DebugClientBase.py	Mon Mar 11 19:00:54 2013 +0100
+++ b/DebugClients/Python/DebugClientBase.py	Wed Mar 13 18:35:24 2013 +0100
@@ -1484,12 +1484,15 @@
             varlist.extend(vlist)
         
             if obj is not None and not formatSequences:
-                if unicode(repr(obj)).startswith('{'):
-                    varlist.append(('...', 'dict', "%d" % len(obj.keys())))
-                elif unicode(repr(obj)).startswith('['):
-                    varlist.append(('...', 'list', "%d" % len(obj)))
-                elif unicode(repr(obj)).startswith('('):
-                    varlist.append(('...', 'tuple', "%d" % len(obj)))
+                try:
+                    if unicode(repr(obj)).startswith('{'):
+                        varlist.append(('...', 'dict', "%d" % len(obj.keys())))
+                    elif unicode(repr(obj)).startswith('['):
+                        varlist.append(('...', 'list', "%d" % len(obj)))
+                    elif unicode(repr(obj)).startswith('('):
+                        varlist.append(('...', 'tuple', "%d" % len(obj)))
+                except:
+                    pass
         
         self.write('%s%s\n' % (DebugProtocol.ResponseVariable, unicode(varlist)))
         
--- a/DebugClients/Python3/DebugBase.py	Mon Mar 11 19:00:54 2013 +0100
+++ b/DebugClients/Python3/DebugBase.py	Wed Mar 13 18:35:24 2013 +0100
@@ -686,7 +686,7 @@
         
         @param exctype type of the exception
         """
-        return repr(exctype).replace("<class '", "").replace("'>", "")
+        return str(exctype).replace("<class '", "").replace("'>", "")
     
     def __extract_stack(self, exctb):
         """
--- a/DebugClients/Python3/DebugClientBase.py	Mon Mar 11 19:00:54 2013 +0100
+++ b/DebugClients/Python3/DebugClientBase.py	Wed Mar 13 18:35:24 2013 +0100
@@ -1517,12 +1517,15 @@
             varlist.extend(vlist)
         
             if obj is not None and not formatSequences:
-                if repr(obj).startswith('{'):
-                    varlist.append(('...', 'dict', "{0:d}".format(len(obj.keys()))))
-                elif repr(obj).startswith('['):
-                    varlist.append(('...', 'list', "{0:d}".format(len(obj))))
-                elif repr(obj).startswith('('):
-                    varlist.append(('...', 'tuple', "{0:d}".format(len(obj))))
+                try:
+                    if repr(obj).startswith('{'):
+                        varlist.append(('...', 'dict', "{0:d}".format(len(obj.keys()))))
+                    elif repr(obj).startswith('['):
+                        varlist.append(('...', 'list', "{0:d}".format(len(obj))))
+                    elif repr(obj).startswith('('):
+                        varlist.append(('...', 'tuple', "{0:d}".format(len(obj))))
+                except:
+                    pass
         
         self.write('{0}{1}\n'.format(DebugProtocol.ResponseVariable, str(varlist)))
         

eric ide

mercurial