[Python-checkins] cpython: faulthandler: only log fatal exceptions

victor.stinner python-checkins at python.org
Wed Mar 23 10:16:09 EDT 2016


https://hg.python.org/cpython/rev/efcc48cd5bfb
changeset:   100690:efcc48cd5bfb
parent:      100688:9d3e7efbc85b
user:        Victor Stinner <victor.stinner at gmail.com>
date:        Wed Mar 23 14:44:14 2016 +0100
summary:
  faulthandler: only log fatal exceptions

Issue #23848, #26622:

* faulthandler now only logs fatal Windows exceptions.
* write error code as decimal, not as hexadecimal
* replace "Windows exception" with "Windows fatal exception"

files:
  Lib/test/test_faulthandler.py |   2 +-
  Modules/faulthandler.c        |  13 ++++++++++---
  2 files changed, 11 insertions(+), 4 deletions(-)


diff --git a/Lib/test/test_faulthandler.py b/Lib/test/test_faulthandler.py
--- a/Lib/test/test_faulthandler.py
+++ b/Lib/test/test_faulthandler.py
@@ -115,7 +115,7 @@
         self.check_error(code, line_number, fatal_error, **kw)
 
     def check_windows_exception(self, code, line_number, name_regex, **kw):
-        fatal_error = 'Windows exception: %s' % name_regex
+        fatal_error = 'Windows fatal exception: %s' % name_regex
         self.check_error(code, line_number, fatal_error, **kw)
 
     @unittest.skipIf(sys.platform.startswith('aix'),
diff --git a/Modules/faulthandler.c b/Modules/faulthandler.c
--- a/Modules/faulthandler.c
+++ b/Modules/faulthandler.c
@@ -367,8 +367,15 @@
 {
     const int fd = fatal_error.fd;
     DWORD code = exc_info->ExceptionRecord->ExceptionCode;
+    DWORD flags = exc_info->ExceptionRecord->ExceptionFlags;
 
-    PUTS(fd, "Windows exception: ");
+    /* only log fatal exceptions */
+    if (flags & EXCEPTION_NONCONTINUABLE) {
+        /* call the next exception handler */
+        return EXCEPTION_CONTINUE_SEARCH;
+    }
+
+    PUTS(fd, "Windows fatal exception: ");
     switch (code)
     {
     /* only format most common errors */
@@ -380,8 +387,8 @@
     case EXCEPTION_IN_PAGE_ERROR: PUTS(fd, "page error"); break;
     case EXCEPTION_STACK_OVERFLOW: PUTS(fd, "stack overflow"); break;
     default:
-        PUTS(fd, "code 0x");
-        _Py_DumpHexadecimal(fd, code, sizeof(DWORD));
+        PUTS(fd, "code ");
+        _Py_DumpDecimal(fd, code, sizeof(DWORD));
     }
     PUTS(fd, "\n\n");
 

-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list