]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Issue 19306: Add extra hints to faulthandler stack dumps that they are upside down.
authorGuido van Rossum <guido@dropbox.com>
Mon, 21 Oct 2013 01:21:02 +0000 (18:21 -0700)
committerGuido van Rossum <guido@dropbox.com>
Mon, 21 Oct 2013 01:21:02 +0000 (18:21 -0700)
Lib/test/test_faulthandler.py
Misc/NEWS
Python/traceback.c

index 2d374b9d6c760a8cb7145622263aeafea4730cf2..ebd99edc8fc4f5a05bddd6c1ff8bb724948450eb 100644 (file)
@@ -72,9 +72,9 @@ class FaultHandlerTests(unittest.TestCase):
         Raise an error if the output doesn't match the expected format.
         """
         if all_threads:
-            header = 'Current thread XXX'
+            header = 'Current thread XXX (most recent call first)'
         else:
-            header = 'Traceback (most recent call first)'
+            header = 'Stack (most recent call first)'
         regex = """
 ^Fatal Python error: {name}
 
@@ -306,7 +306,7 @@ funcA()
         else:
             lineno = 8
         expected = [
-            'Traceback (most recent call first):',
+            'Stack (most recent call first):',
             '  File "<string>", line %s in funcB' % lineno,
             '  File "<string>", line 11 in funcA',
             '  File "<string>", line 13 in <module>'
@@ -338,7 +338,7 @@ def {func_name}():
             func_name=func_name,
         )
         expected = [
-            'Traceback (most recent call first):',
+            'Stack (most recent call first):',
             '  File "<string>", line 4 in %s' % truncated,
             '  File "<string>", line 6 in <module>'
         ]
@@ -392,13 +392,13 @@ waiter.join()
         else:
             lineno = 10
         regex = """
-^Thread 0x[0-9a-f]+:
+^Thread 0x[0-9a-f]+ \(most recent call first\):
 (?:  File ".*threading.py", line [0-9]+ in [_a-z]+
 ){{1,3}}  File "<string>", line 23 in run
   File ".*threading.py", line [0-9]+ in _bootstrap_inner
   File ".*threading.py", line [0-9]+ in _bootstrap
 
-Current thread XXX:
+Current thread XXX \(most recent call first\):
   File "<string>", line {lineno} in dump
   File "<string>", line 28 in <module>$
 """.strip()
@@ -461,7 +461,7 @@ if file is not None:
             count = loops
             if repeat:
                 count *= 2
-            header = r'Timeout \(%s\)!\nThread 0x[0-9a-f]+:\n' % timeout_str
+            header = r'Timeout \(%s\)!\nThread 0x[0-9a-f]+ \(most recent call first\):\n' % timeout_str
             regex = expected_traceback(9, 20, header, min_count=count)
             self.assertRegex(trace, regex)
         else:
@@ -563,9 +563,9 @@ sys.exit(exitcode)
         trace = '\n'.join(trace)
         if not unregister:
             if all_threads:
-                regex = 'Current thread XXX:\n'
+                regex = 'Current thread XXX \(most recent call first\):\n'
             else:
-                regex = 'Traceback \(most recent call first\):\n'
+                regex = 'Stack \(most recent call first\):\n'
             regex = expected_traceback(7, 28, regex)
             self.assertRegex(trace, regex)
         else:
index 8a31887d7f6d98dd170aaeaa724ef01985557133..379dfd70a5da3620104afe9c969a62b11011962e 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -2,10 +2,21 @@
 Python News
 +++++++++++
 
+What's New in Python 3.4.0 Beta 1?
+==================================
+
+Projected release date: 2013-11-24
+
+Core and Builtins
+-----------------
+
+- Issue 19306: Add extra hints to the faulthandler module's stack
+  dumps that these are "upside down".
+
 What's New in Python 3.4.0 Alpha 4?
-================================
+===================================
 
-Projected release date: 2013-10-20
+Release date: 2013-10-20
 
 Core and Builtins
 -----------------
index 4f2e732779db2f6073681ec2cdf59f0fa5fb1ed0..01e947315a89e33b4162cb5b1547ef8c82db5901 100644 (file)
@@ -471,13 +471,13 @@ dump_decimal(int fd, int value)
     write(fd, buffer, len);
 }
 
-/* Format an integer in range [0; 0xffffffff] to hexdecimal of 'width' digits,
+/* Format an integer in range [0; 0xffffffff] to hexadecimal of 'width' digits,
    and write it into the file fd.
 
    This function is signal safe. */
 
 static void
-dump_hexadecimal(int width, unsigned long value, int fd)
+dump_hexadecimal(int fd, unsigned long value, int width)
 {
     int len;
     char buffer[sizeof(unsigned long) * 2 + 1];
@@ -544,15 +544,15 @@ dump_ascii(int fd, PyObject *text)
         }
         else if (ch < 0xff) {
             PUTS(fd, "\\x");
-            dump_hexadecimal(2, ch, fd);
+            dump_hexadecimal(fd, ch, 2);
         }
         else if (ch < 0xffff) {
             PUTS(fd, "\\u");
-            dump_hexadecimal(4, ch, fd);
+            dump_hexadecimal(fd, ch, 4);
         }
         else {
             PUTS(fd, "\\U");
-            dump_hexadecimal(8, ch, fd);
+            dump_hexadecimal(fd, ch, 8);
         }
     }
     if (truncated)
@@ -603,7 +603,7 @@ dump_traceback(int fd, PyThreadState *tstate, int write_header)
     unsigned int depth;
 
     if (write_header)
-        PUTS(fd, "Traceback (most recent call first):\n");
+        PUTS(fd, "Stack (most recent call first):\n");
 
     frame = _PyThreadState_GetFrame(tstate);
     if (frame == NULL)
@@ -641,8 +641,8 @@ write_thread_id(int fd, PyThreadState *tstate, int is_current)
         PUTS(fd, "Current thread 0x");
     else
         PUTS(fd, "Thread 0x");
-    dump_hexadecimal(sizeof(long)*2, (unsigned long)tstate->thread_id, fd);
-    PUTS(fd, ":\n");
+    dump_hexadecimal(fd, (unsigned long)tstate->thread_id, sizeof(long)*2);
+    PUTS(fd, " (most recent call first):\n");
 }
 
 const char*