File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -754,6 +754,32 @@ def test_raise_exception(self):
754754 3 ,
755755 name )
756756
757+ @unittest .skipUnless (MS_WINDOWS , 'specific to Windows' )
758+ def test_raise_nonfatal_exception (self ):
759+ # These exceptions are not strictly errors. Letting
760+ # faulthandler display the traceback when they are
761+ # raised is likely to result in noise. However, they
762+ # may still terminate the process if there is no
763+ # handler installed for them (which there typically
764+ # is, e.g. for debug messages).
765+ for exc in (
766+ 0x00000000 ,
767+ 0x34567890 ,
768+ 0x40000000 ,
769+ 0x40001000 ,
770+ 0x70000000 ,
771+ 0x7FFFFFFF ,
772+ ):
773+ output , exitcode = self .get_output (f"""
774+ import faulthandler
775+ faulthandler.enable()
776+ faulthandler._raise_exception(0x{ exc :x} )
777+ """
778+ )
779+ self .assertEqual (output , [])
780+ # Actual exception code has bit 4 cleared
781+ self .assertEqual (exitcode , exc & ~ 0x10000000 )
782+
757783 @unittest .skipUnless (MS_WINDOWS , 'specific to Windows' )
758784 def test_disable_windows_exc_handler (self ):
759785 code = dedent ("""
Original file line number Diff line number Diff line change @@ -345,6 +345,9 @@ Extension Modules
345345Library
346346-------
347347
348+ - bpo-30557: faulthandler now correctly filters and displays exception codes
349+ on Windows
350+
348351- bpo-30526: Add TextIOWrapper.reconfigure() and a TextIOWrapper.write_through
349352 attribute.
350353
Original file line number Diff line number Diff line change @@ -373,8 +373,8 @@ faulthandler_exc_handler(struct _EXCEPTION_POINTERS *exc_info)
373373 DWORD code = exc_info -> ExceptionRecord -> ExceptionCode ;
374374 DWORD flags = exc_info -> ExceptionRecord -> ExceptionFlags ;
375375
376- /* only log fatal exceptions */
377- if (flags & EXCEPTION_NONCONTINUABLE ) {
376+ /* bpo-30557: only log fatal exceptions */
377+ if (!( code & 0x80000000 ) ) {
378378 /* call the next exception handler */
379379 return EXCEPTION_CONTINUE_SEARCH ;
380380 }
@@ -391,8 +391,8 @@ faulthandler_exc_handler(struct _EXCEPTION_POINTERS *exc_info)
391391 case EXCEPTION_IN_PAGE_ERROR : PUTS (fd , "page error" ); break ;
392392 case EXCEPTION_STACK_OVERFLOW : PUTS (fd , "stack overflow" ); break ;
393393 default :
394- PUTS (fd , "code " );
395- _Py_DumpDecimal (fd , code );
394+ PUTS (fd , "code 0x " );
395+ _Py_DumpHexadecimal (fd , code , 8 );
396396 }
397397 PUTS (fd , "\n\n" );
398398
You can’t perform that action at this time.
0 commit comments