eric6/DebugClients/Python/DebugBase.py

branch
maintenance
changeset 8273
698ae46f40a4
parent 8043
0acf98cd089a
parent 8257
28146736bbfc
equal deleted inserted replaced
8190:fb0ef164f536 8273:698ae46f40a4
13 import atexit 13 import atexit
14 import inspect 14 import inspect
15 import ctypes 15 import ctypes
16 import time 16 import time
17 import dis 17 import dis
18 import contextlib
18 19
19 from BreakpointWatch import Breakpoint, Watch 20 from BreakpointWatch import Breakpoint, Watch
20 21
21 import _thread 22 import _thread
22 from DebugUtilities import getargvalues, formatargvalues 23 from DebugUtilities import getargvalues, formatargvalues
51 """ 52 """
52 global gRecursionLimit 53 global gRecursionLimit
53 gRecursionLimit = limit 54 gRecursionLimit = limit
54 55
55 56
56 class DebugBase(object): 57 class DebugBase:
57 """ 58 """
58 Class implementing base class of the debugger. 59 Class implementing base class of the debugger.
59 60
60 Provides methods for the 'owning' client to call to step etc. 61 Provides methods for the 'owning' client to call to step etc.
61 """ 62 """
166 cf = self.currentFrame 167 cf = self.currentFrame
167 while cf is not None and frmnr > 0: 168 while cf is not None and frmnr > 0:
168 cf = cf.f_back 169 cf = cf.f_back
169 frmnr -= 1 170 frmnr -= 1
170 171
171 try: 172 with contextlib.suppress(Exception):
172 if "__pypy__" in sys.builtin_module_names: 173 if "__pypy__" in sys.builtin_module_names:
173 import __pypy__ 174 import __pypy__
174 __pypy__.locals_to_fast(cf) 175 __pypy__.locals_to_fast(cf)
175 return 176 return
176 except Exception: # secok
177 pass
178 177
179 ctypes.pythonapi.PyFrame_LocalsToFast( 178 ctypes.pythonapi.PyFrame_LocalsToFast(
180 ctypes.py_object(cf), 179 ctypes.py_object(cf),
181 ctypes.c_int(0)) 180 ctypes.c_int(0))
182 181
332 if event == 'call': 331 if event == 'call':
333 if ( 332 if (
334 self.stop_here(frame) or 333 self.stop_here(frame) or
335 self.__checkBreakInFrame(frame) or 334 self.__checkBreakInFrame(frame) or
336 Watch.watches != [] 335 Watch.watches != []
337 ): 336 ) or (
338 return self.trace_dispatch
339 elif (
340 self.stopframe and 337 self.stopframe and
341 frame.f_code.co_flags & GENERATOR_AND_COROUTINE_FLAGS 338 frame.f_code.co_flags & GENERATOR_AND_COROUTINE_FLAGS
342 ): 339 ):
343 return self.trace_dispatch 340 return self.trace_dispatch
344 else: 341 else:
923 exctype = self.__extractExceptionName(exctype) 920 exctype = self.__extractExceptionName(exctype)
924 921
925 if excval is None: 922 if excval is None:
926 excval = '' 923 excval = ''
927 924
928 if unhandled: 925 exctypetxt = (
929 exctypetxt = "unhandled {0!s}".format(str(exctype)) 926 "unhandled {0!s}".format(str(exctype))
930 else: 927 if unhandled else
931 exctypetxt = str(exctype) 928 str(exctype)
932 929 )
933 excvaltxt = str(excval) 930 excvaltxt = str(excval)
934 931
935 # Don't step into libraries, which are used by our debugger methods 932 # Don't step into libraries, which are used by our debugger methods
936 if exctb is not None: 933 if exctb is not None:
937 self.stop_everywhere = False 934 self.stop_everywhere = False

eric ide

mercurial