Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork34.2k
gh-145559: Add PyUnstable_DumpTraceback() and PyUnstable_DumpTracebackThreads()#145560
gh-145559: Add PyUnstable_DumpTraceback() and PyUnstable_DumpTracebackThreads()#145560alexmalyshev wants to merge 6 commits intopython:mainfrom
Conversation
Most changes to Pythonrequire a NEWS entry. Add one using theblurb_it web app or theblurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the |
vstinner commentedMar 5, 2026
Rather than exporting internal C API functions, I would prefer to promote them as public or PyUnstable functions. |
Most changes to Pythonrequire a NEWS entry. Add one using theblurb_it web app or theblurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the |
alexmalyshev commentedMar 5, 2026
Made them PyUnsafe_ functions. Ibelieve that the mentions to them in the configure and emscripten files can just be deleted now that they'll be public. |
sergey-miryanov commentedMar 5, 2026
I believe they should have |
alexmalyshev commentedMar 5, 2026
Ack I always make this mistake... |
…functionsThese functions stopped being exported inpython#107215. However, they are the onlyway to print a Python stacktrace safely from a signal handler, making them veryuseful for extensions. Re-export them as PyUnstable functions.
sergey-miryanov commentedMar 5, 2026
Please,try to avoid force-push. |
freakboy3742 commentedMar 5, 2026
!buildbot emscripten |
bedevere-bot commentedMar 5, 2026
🤖 New build scheduled with the buildbot fleet by@freakboy3742 for commit538a1cd 🤖 Results will be shown at: https://buildbot.python.org/all/#/grid?branch=refs%2Fpull%2F145560%2Fmerge The command will test the builders whose names match following regular expression: The builders matched are:
|
ZeroIntensity left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Note thatPyUnstable_DumpTracebackThreads does not work well on the free-threaded build, because other threads may exit and delete theirPyThreadState *. I think it's worth adding a warning for that. Here's an example:
..warning:: On the:term:`free-threaded build`, this function is not thread-safe. If another thread deletes its:term:`thread state` while this function is being called, the process will likely crash.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Include/cpython/traceback.h Outdated
| it is very limited. Strings are truncated to 100 characters and encoded to | ||
| ASCII with backslashreplace. It doesn't write the source code, only the | ||
| function name, filename and line number of each frame. Write only the first | ||
| 100 frames: if the traceback is truncated, write the line " ...". |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
It sounds useful to move or copy this comment into the Doc/c-api/ documentation. Same remark for PyUnstable_DumpTracebackThreads() comment.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Comment says 100, but it appears to have been 500 since 2012,54f939b.
ZeroIntensity left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
ZeroIntensity left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
One little issue with the blurb entry, but otherwise this looks good.
| @@ -0,0 +1 @@ | |||
| Rename `_Py_DumpTraceback` and `_Py_DumpTracebackThreads` to `PyUnstable_DumpTraceback` and `PyUnstable_DumpTracebackThreads`. | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
| Rename `_Py_DumpTraceback` and `_Py_DumpTracebackThreads` to `PyUnstable_DumpTraceback` and `PyUnstable_DumpTracebackThreads`. | |
| Rename ``_Py_DumpTraceback`` and ``_Py_DumpTracebackThreads`` to:c:func:`PyUnstable_DumpTraceback` and:c:func:`PyUnstable_DumpTracebackThreads`. |
Uh oh!
There was an error while loading.Please reload this page.
These functions stopped being exported in#107215. However, they are the only way to print a Python stacktrace safely from a signal handler, making them very useful for extensions. Re-export them.