New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Warn unsuspecting readers that thread stacks are in reverse order #63505
Comments
I was confused for a while when seeing the thread stacks dumped by the faulthandler module. (See bpo-19293.) I propose the following tweaks of the output to make this more obvious. The first chunk changes the header written when called as _Py_DumpTraceback(), the second change the per-thread headers printed by _Py_DumpTracebackThreads(). diff -r 02f6922e6a7e Python/traceback.c
--- a/Python/traceback.c Sat Oct 19 17:04:25 2013 -0700
+++ b/Python/traceback.c Sat Oct 19 17:19:29 2013 -0700
@@ -603,7 +603,7 @@
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)
@@ -642,7 +642,7 @@
else
PUTS(fd, "Thread 0x");
dump_hexadecimal(sizeof(long)*2, (unsigned long)tstate->thread_id, fd);
- PUTS(fd, ":\n");
+ PUTS(fd, " (most recent call first):\n");
} const char* |
BTW, another oddity in traceback.c: dump_hexadecimal() has the "int fd" argument at the end, while all other dump_*() functions have it at the front -- even its cousin dump_decimal(). Here's a patch that includes a fix. |
You must update unit tests in test_faulthandler. |
New patch, with fixed test. TBH now I'm getting worried that other programs may exist that parse this format and will get confused. |
A program parsing faulthandler output? Seriously? It would be nice, but I don't know any. Anyway, such program would probably use a regex to parse the output, and it's very easy to support Python 3.3 format and patched (future 3.4) format.
Thanks. The patch looks good to me, you can push it. |
New changeset cc8c37b5b449 by Guido van Rossum in branch 'default': |
On Victor's authority, committed. I've also (separately) committed some doc changes. |
Thanks. "(most recent call first)" was already present in some cases, but I forgot to mention it in all cases. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: