Skip to content
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

Document pdb.post_mortem() accepts exceptions on Python 3.13+ #128409

Open
adamchainz opened this issue Jan 2, 2025 · 1 comment · May be fixed by #128410
Open

Document pdb.post_mortem() accepts exceptions on Python 3.13+ #128409

adamchainz opened this issue Jan 2, 2025 · 1 comment · May be fixed by #128410
Labels
docs Documentation in the Doc dir

Comments

@adamchainz
Copy link
Contributor

adamchainz commented Jan 2, 2025

Documentation

Some change in Python 3.13 (maybe 5f3433f or related) allows pdb.post_mortem() to accept an exception object, as well as a traceback object. This could be useful to use for chained exception access, for example in Django’s test runner where a traceback is currently passed, but the exception with chained causes is available.

Tested with:

import pdb

try:
    try:
        1 / 0
    except Exception:
        2 / 0
except Exception as exc:
    pdb.post_mortem(exc)

and ran with:

$ uv run -p 3.13 python example.py
> /.../example.py(7)<module>()
-> 2 / 0
(Pdb) exceptions
    0 ZeroDivisionError('division by zero')
>   1 ZeroDivisionError('division by zero')
(Pdb) exceptions 0
> /.../example.py(5)<module>()
-> 1 / 0
(Pdb)

Linked PRs

@adamchainz adamchainz added the docs Documentation in the Doc dir label Jan 2, 2025
adamchainz added a commit to adamchainz/cpython that referenced this issue Jan 2, 2025
@adamchainz
Copy link
Contributor Author

pytest is already taking advantage of this “secret feature“: pytest-dev/pytest#12707

adamchainz added a commit to adamchainz/cpython that referenced this issue Jan 3, 2025
co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
adamchainz added a commit to adamchainz/cpython that referenced this issue Jan 3, 2025
co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation in the Doc dir
Projects
Status: Todo
Development

Successfully merging a pull request may close this issue.

1 participant