MCPcopy Create free account
hub / github.com/fabioz/PyDev.Debugger / runcode

Method runcode

_pydevd_bundle/pydevconsole_code.py:306–336  ·  view source on GitHub ↗

Execute a code object. When an exception occurs, self.showtraceback() is called to display a traceback. All exceptions are caught except SystemExit, which is reraised. A note about KeyboardInterrupt: this exception may occur elsewhere in this code, and may

(self, code)

Source from the content-addressed store, hash-verified

304 return False
305
306 def runcode(self, code):
307 """Execute a code object.
308
309 When an exception occurs, self.showtraceback() is called to
310 display a traceback. All exceptions are caught except
311 SystemExit, which is reraised.
312
313 A note about KeyboardInterrupt: this exception may occur
314 elsewhere in this code, and may not always be caught. The
315 caller should be prepared to deal with it.
316
317 """
318 try:
319 is_async = False
320 if hasattr(inspect, "CO_COROUTINE"):
321 is_async = inspect.CO_COROUTINE & code.co_flags == inspect.CO_COROUTINE
322
323 if is_async:
324 t = _EvalAwaitInNewEventLoop(code, self.locals, None)
325 t.start()
326 t.join()
327
328 if t.exc:
329 raise t.exc[1].with_traceback(t.exc[2])
330
331 else:
332 exec(code, self.locals)
333 except SystemExit:
334 raise
335 except:
336 self.showtraceback()
337
338 def showsyntaxerror(self, filename=None):
339 """Display the syntax error that just occurred.

Callers 1

runsourceMethod · 0.95

Calls 4

showtracebackMethod · 0.95
startMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected