-
Notifications
You must be signed in to change notification settings - Fork 52
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
pyflyby-dbg: Support chained exceptions #381
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This commit adds support of stepping through chained exceptions with pyflyby debugger. ``` $ cat chained_exc.py ------------------------------------------------------------- def inner(): raise ValueError("inner") def outer(): try: inner() except Exception as e: raise ValueError("outer") from e if __name__ == "__main__": outer() -------------------------------------------------------------------------- $ py /u/anis/scratch/chained_exc.py --------------------------------------------------------------------------- ValueError Traceback (most recent call last) File ~/scratch/chained_exc.py:6, in outer() 5 try: ----> 6 inner() 7 except Exception as e: File ~/scratch/chained_exc.py:2, in inner() 1 def inner(): ----> 2 raise ValueError("inner") ValueError: inner The above exception was the direct cause of the following exception: ValueError Traceback (most recent call last) File ~/scratch/chained_exc.py:11 8 raise ValueError("outer") from e 10 if __name__ == "__main__": ---> 11 outer() File ~/scratch/chained_exc.py:8, in outer() 6 inner() 7 except Exception as e: ----> 8 raise ValueError("outer") from e ValueError: outer > /u/anis/scratch/chained_exc.py(8)outer() 6 inner() 7 except Exception as e: ----> 8 raise ValueError("outer") from e 9 10 if __name__ == "__main__": ipdb> exceptions 0 ValueError('inner') > 1 ValueError('outer') ``` The support uses native Ipython's debugger or python's pdb support for chained exceptions and is available with `exceptions` command under ipdb/pdb command prompt. Implementation notes ============================================================= Starting Py3.13, pdb.interaction() supports chained exceptions in case exception (and not traceback) is specified. This support is backported to IPython8.16 for earlier Python versions. So the conditions where chained exceptions won't be supported from pyflyby's debugger would be with Python version < 3.13 and ipython is not being installed, or IPython's version is lesser than 8.16. Ref: PyInf#14001 Reviewer: dhamodha
@dshivashankar1994 Could you please review the change here? |
dshivashankar1994
approved these changes
Nov 27, 2024
Carreau
reviewed
Dec 2, 2024
Carreau
approved these changes
Dec 2, 2024
Thanks for the comments @Carreau. I will address them. |
umairanis03
force-pushed
the
dbg-chain-exc
branch
from
December 4, 2024 13:27
9419bf0
to
f564ad4
Compare
@Carreau I have addressed the comments. Please have a look. |
@Carreau Please merge the change as well if it looks good to you. |
Thanks. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This commit adds support of stepping through chained exceptions with pyflyby debugger.
The support uses native Ipython's debugger or python's pdb support for chained exceptions and is available with
exceptions
command under ipdb/pdb command prompt.Implementation notes
Starting Py3.13, pdb.interaction() supports chained exceptions in case exception (and not traceback) is specified. This support is backported to IPython8.16 for earlier Python versions. So the conditions where chained exceptions won't be supported from pyflyby's debugger would be with Python version < 3.13 and ipython is not being installed, or IPython's version is lesser than 8.16.
Ref: PyInf#14001
Reviewer: dhamodha