Skip to content

Add PyUnstable_DumpTraceback() and PyUnstable_DumpTracebackThreads() #101

@vstinner

Description

@vstinner

Hi,

@alexmalyshev proposes adding PyUnstable_DumpTraceback() and PyUnstable_DumpTracebackThreads() functions to dump the Python traceback to a file descriptor:

const char* PyUnstable_DumpTraceback(int fd, PyThreadState *tstate);
const char* PyUnstable_DumpTracebackThreads(int fd, PyInterpreterState *interp, PyThreadState *current_tstate);

These functions are safe to use from signal handlers. The caller does not need to hold an attached thread state.

If PyUnstable_DumpTraceback() or PyUnstable_DumpTracebackThreads() cannot dump the traceback, it returns an error message. The caller is free to ignore it, or to report it someho to the user. It cannot raise an exception since it can be called without an attached thread state.

See the issue and the pull request. See the pull request for the whole API.

UPDATE: Change PyUnstable_DumpTraceback() return type from void to const char*.

Vote to add these 2 functions:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions