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

Function exception_break

pydevd_plugins/jinja2_debug.py:497–528  ·  view source on GitHub ↗
(pydb, frame, thread, arg, is_unwind)

Source from the content-addressed store, hash-verified

495
496
497def exception_break(pydb, frame, thread, arg, is_unwind):
498 exception, value, trace = arg
499 if pydb.jinja2_exception_break and exception is not None:
500 exception_type = list(pydb.jinja2_exception_break.keys())[0]
501 if exception.__name__ in ("UndefinedError", "TemplateNotFound", "TemplatesNotFound"):
502 # errors in rendering
503 render_frame = _find_jinja2_render_frame(frame)
504 if render_frame:
505 suspend_frame = _suspend_jinja2(pydb, thread, render_frame, CMD_ADD_EXCEPTION_BREAK, message=exception_type)
506 if suspend_frame:
507 add_exception_to_frame(suspend_frame, (exception, value, trace))
508 suspend_frame.f_back = frame
509 frame = suspend_frame
510 return True, frame
511
512 elif exception.__name__ in ("TemplateSyntaxError", "TemplateAssertionError"):
513 name = frame.f_code.co_name
514
515 # errors in compile time
516 if name in ("template", "top-level template code", "<module>") or name.startswith("block "):
517 f_back = frame.f_back
518 if f_back is not None:
519 module_name = f_back.f_globals.get("__name__", "")
520
521 if module_name.startswith("jinja2."):
522 # Jinja2 translates exception info and creates fake frame on his own
523 pydb.set_suspend(thread, CMD_ADD_EXCEPTION_BREAK)
524 add_exception_to_frame(frame, (exception, value, trace))
525 thread.additional_info.suspend_type = JINJA2_SUSPEND
526 thread.additional_info.pydev_message = str(exception_type)
527 return True, frame
528 return None

Callers

nothing calls this directly

Calls 6

add_exception_to_frameFunction · 0.90
_suspend_jinja2Function · 0.85
keysMethod · 0.80
getMethod · 0.45
set_suspendMethod · 0.45

Tested by

no test coverage detected