@@ -980,29 +980,32 @@ def _raise_event(code, instruction, exc):
980980 if func_code_info .always_skip_code :
981981 return
982982
983- _clear_unhandled_exception_frame ()
983+ frame = _getframe (1 )
984+ arg = (type (exc ), exc , exc .__traceback__ )
984985
985- has_caught_exception_breakpoint_in_pydb = (
986- py_db .break_on_caught_exceptions or py_db .break_on_user_uncaught_exceptions or py_db .has_plugin_exception_breaks
986+ # Compute the previous exception info (if any). We use it to check if the exception
987+ # should be stopped
988+ prev_exc_info = _thread_local_info ._user_uncaught_exc_info if hasattr (_thread_local_info , "_user_uncaught_exc_info" ) else None
989+ should_stop , frame , _user_uncaught_exc_info = should_stop_on_exception (
990+ py_db , thread_info .additional_info , frame , thread_info .thread , arg , prev_exc_info
987991 )
988992
989- if has_caught_exception_breakpoint_in_pydb :
990- frame = _getframe (1 )
991- arg = (type (exc ), exc , exc .__traceback__ )
992-
993- # Compute the previous exception info (if any). We use it to check if the exception
994- # should be stopped
995- prev_exc_info = _thread_local_info ._user_uncaught_exc_info if hasattr (_thread_local_info , "_user_uncaught_exc_info" ) else None
996- should_stop , frame , _user_uncaught_exc_info = should_stop_on_exception (
997- py_db , thread_info .additional_info , frame , thread_info .thread , arg , prev_exc_info
998- )
993+ # Save the current exception info for the next raise event.
994+ _thread_local_info ._user_uncaught_exc_info = _user_uncaught_exc_info
999995
1000- # Save the current exception info for the next raise event.
1001- _thread_local_info ._user_uncaught_exc_info = _user_uncaught_exc_info
996+ # print('!!!! should_stop (in raise)', should_stop)
997+ if should_stop :
998+ handle_exception (py_db , thread_info .thread , frame , arg , EXCEPTION_TYPE_HANDLED )
1002999
1003- # print('!!!! should_stop (in raise)', should_stop)
1004- if should_stop :
1005- handle_exception (py_db , thread_info .thread , frame , arg , EXCEPTION_TYPE_HANDLED )
1000+
1001+ # fmt: off
1002+ # IFDEF CYTHON
1003+ # cdef _raise_event_uncaught(code, instruction, exc):
1004+ # ELSE
1005+ def _raise_event_uncaught (code , instruction , exc ):
1006+ # ENDIF
1007+ # fmt: on
1008+ _clear_unhandled_exception_frame ()
10061009
10071010
10081011# fmt: off
@@ -1892,7 +1895,7 @@ def update_monitor_events(suspend_requested: Optional[bool]=None) -> None:
18921895 monitor .register_callback (DEBUGGER_ID , monitor .events .PY_UNWIND , _unwind_event )
18931896 elif break_on_uncaught_exceptions :
18941897 required_events |= monitor .events .RAISE | monitor .events .PY_UNWIND
1895- monitor .register_callback (DEBUGGER_ID , monitor .events .RAISE , _raise_event )
1898+ monitor .register_callback (DEBUGGER_ID , monitor .events .RAISE , _raise_event_uncaught )
18961899 monitor .register_callback (DEBUGGER_ID , monitor .events .PY_UNWIND , _unwind_event )
18971900 else :
18981901 monitor .register_callback (DEBUGGER_ID , monitor .events .RAISE , None )
0 commit comments