@@ -986,29 +986,54 @@ cdef _raise_event(code, instruction, exc):
986986 if func_code_info.always_skip_code:
987987 return
988988
989- _clear_unhandled_exception_frame()
989+ frame = _getframe(1 )
990+ arg = (type (exc), exc, exc.__traceback__)
990991
991- has_caught_exception_breakpoint_in_pydb = (
992- py_db.break_on_caught_exceptions or py_db.break_on_user_uncaught_exceptions or py_db.has_plugin_exception_breaks
992+ # Compute the previous exception info (if any). We use it to check if the exception
993+ # should be stopped
994+ prev_exc_info = _thread_local_info._user_uncaught_exc_info if hasattr (_thread_local_info, " _user_uncaught_exc_info" ) else None
995+ should_stop, frame, _user_uncaught_exc_info = should_stop_on_exception(
996+ py_db, thread_info.additional_info, frame, thread_info.thread, arg, prev_exc_info
993997 )
994998
995- if has_caught_exception_breakpoint_in_pydb:
996- frame = _getframe(1 )
997- arg = (type (exc), exc, exc.__traceback__)
998-
999- # Compute the previous exception info (if any). We use it to check if the exception
1000- # should be stopped
1001- prev_exc_info = _thread_local_info._user_uncaught_exc_info if hasattr (_thread_local_info, " _user_uncaught_exc_info" ) else None
1002- should_stop, frame, _user_uncaught_exc_info = should_stop_on_exception(
1003- py_db, thread_info.additional_info, frame, thread_info.thread, arg, prev_exc_info
1004- )
999+ # Save the current exception info for the next raise event.
1000+ _thread_local_info._user_uncaught_exc_info = _user_uncaught_exc_info
10051001
1006- # Save the current exception info for the next raise event.
1007- _thread_local_info._user_uncaught_exc_info = _user_uncaught_exc_info
1002+ # print('!!!! should_stop (in raise)', should_stop)
1003+ if should_stop:
1004+ handle_exception(py_db, thread_info.thread, frame, arg, EXCEPTION_TYPE_HANDLED)
10081005
1009- # print('!!!! should_stop (in raise)', should_stop)
1010- if should_stop:
1011- handle_exception(py_db, thread_info.thread, frame, arg, EXCEPTION_TYPE_HANDLED)
1006+
1007+ # fmt: off
1008+ # IFDEF CYTHON -- DONT EDIT THIS FILE (it is automatically generated)
1009+ cdef _raise_event_uncaught(code, instruction, exc):
1010+ cdef ThreadInfo thread_info
1011+ cdef FuncCodeInfo func_code_info
1012+ # ELSE
1013+ # def _raise_event_uncaught(code, instruction, exc):
1014+ # ENDIF
1015+ # fmt: on
1016+ try :
1017+ thread_info = _thread_local_info.thread_info
1018+ except :
1019+ thread_info = _get_thread_info(True , 1 )
1020+ if thread_info is None :
1021+ return
1022+
1023+ py_db: object = GlobalDebuggerHolder.global_dbg
1024+ if py_db is None or py_db.pydb_disposed:
1025+ return
1026+
1027+ if not thread_info.trace or not thread_info.is_thread_alive():
1028+ # For thread-related stuff we can't disable the code tracing because other
1029+ # threads may still want it...
1030+ return
1031+
1032+ func_code_info: FuncCodeInfo = _get_func_code_info(code, 1 )
1033+ if func_code_info.always_skip_code:
1034+ return
1035+
1036+ _clear_unhandled_exception_frame()
10121037
10131038
10141039# fmt: off
@@ -1898,7 +1923,7 @@ def update_monitor_events(suspend_requested: Optional[bool]=None) -> None:
18981923 monitor.register_callback(DEBUGGER_ID, monitor.events.PY_UNWIND, _unwind_event)
18991924 elif break_on_uncaught_exceptions:
19001925 required_events |= monitor.events.RAISE | monitor.events.PY_UNWIND
1901- monitor.register_callback(DEBUGGER_ID, monitor.events.RAISE, _raise_event )
1926+ monitor.register_callback(DEBUGGER_ID, monitor.events.RAISE, _raise_event_uncaught )
19021927 monitor.register_callback(DEBUGGER_ID, monitor.events.PY_UNWIND, _unwind_event)
19031928 else :
19041929 monitor.register_callback(DEBUGGER_ID, monitor.events.RAISE, None )
0 commit comments