eric6/DebugClients/Python/DebugBase.py

branch
multi_processing
changeset 7646
39e3db2b4936
parent 7564
787684e6f2f3
parent 7639
422fd05e9c91
child 7802
eefe954f01e8
--- a/eric6/DebugClients/Python/DebugBase.py	Wed Jun 17 17:14:12 2020 +0200
+++ b/eric6/DebugClients/Python/DebugBase.py	Sun Jul 05 11:11:24 2020 +0200
@@ -17,14 +17,8 @@
 
 from BreakpointWatch import Breakpoint, Watch
 
-if sys.version_info[0] == 2:
-    import thread as _thread
-    from inspect import getargvalues, formatargvalues
-else:
-    import _thread
-    from DebugUtilities import getargvalues, formatargvalues
-    unicode = str
-    basestring = str
+import _thread
+from DebugUtilities import getargvalues, formatargvalues
 
 gRecursionLimit = 64
 
@@ -169,7 +163,7 @@
                 import __pypy__
                 __pypy__.locals_to_fast(cf)
                 return
-        except Exception:
+        except Exception:       # secok
             pass
         
         ctypes.pythonapi.PyFrame_LocalsToFast(
@@ -383,10 +377,7 @@
         if frame is None:
             frame = sys._getframe().f_back  # Skip set_trace method
         
-        if sys.version_info[0] == 2:
-            stopOnHandleCommand = self._dbgClient.handleJsonCommand.func_code
-        else:
-            stopOnHandleCommand = self._dbgClient.handleJsonCommand.__code__
+        stopOnHandleCommand = self._dbgClient.handleJsonCommand.__code__
         
         frame.f_trace = self.trace_dispatch
         while frame.f_back is not None:
@@ -461,7 +452,7 @@
             sys.settrace(self.trace_dispatch)
         
         try:
-            exec(cmd, globalsDict, localsDict)
+            exec(cmd, globalsDict, localsDict)      # secok
             atexit._run_exitfuncs()
             self._dbgClient.progTerminated(0)
             exitcode = 0
@@ -626,10 +617,7 @@
             lineNo = frame.f_code.co_firstlineno
             lineNumbers = [lineNo]
             
-            if sys.version_info[0] == 2:
-                co_lnotab = map(ord, frame.f_code.co_lnotab[1::2])
-            else:
-                co_lnotab = frame.f_code.co_lnotab[1::2]
+            co_lnotab = frame.f_code.co_lnotab[1::2]
             
             # No need to handle special case if a lot of lines between
             # (e.g. closure), because the additional lines won't cause a bp
@@ -816,7 +804,6 @@
         
         if exctype in [SyntaxError, IndentationError]:
             try:
-                # tuple could only occure on Python 2, but not always!
                 if type(excval) == tuple:
                     message, details = excval
                     filename, lineno, charno, text = details
@@ -877,13 +864,7 @@
         else:
             exctypetxt = str(exctype)
         
-        if sys.version_info[0] == 2:
-            try:
-                excvaltxt = unicode(excval).encode(self._dbgClient.getCoding())
-            except UnicodeError:
-                excvaltxt = str(excval)
-        else:
-            excvaltxt = str(excval)
+        excvaltxt = str(excval)
         
         # Don't step into libraries, which are used by our debugger methods
         if exctb is not None:
@@ -931,14 +912,7 @@
         @param exctype type of the exception
         @return exception name (string)
         """
-        if sys.version_info[0] == 2:
-            if type(exctype) in [types.ClassType,   # Python up to 2.4
-                                 types.TypeType]:   # Python 2.5+
-                return exctype.__name__
-            else:
-                return exctype
-        else:
-            return exctype.__name__
+        return str(exctype).replace("<class '", "").replace("'>", "")
     
     def __extract_stack(self, exctb):
         """
@@ -968,7 +942,7 @@
         if excval is None:
             exitcode = 0
             message = ""
-        elif isinstance(excval, basestring):
+        elif isinstance(excval, str):
             exitcode = 1
             message = excval
         elif isinstance(excval, bytes):
@@ -979,7 +953,7 @@
             message = ""
         elif isinstance(excval, SystemExit):
             code = excval.code
-            if isinstance(code, basestring):
+            if isinstance(code, str):
                 exitcode = 1
                 message = code
             elif isinstance(code, bytes):
@@ -1060,6 +1034,3 @@
         except AttributeError:
             # if frame is None
             return True
-    
-#
-# eflag: noqa = M702

eric ide

mercurial