This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: pdb: store whole exception information in locals (via user_exception)
Type: Stage: resolved
Components: Library (Lib) Versions: Python 3.9
process
Status: closed Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: blueyed, iritkatriel
Priority: normal Keywords:

Created on 2019-04-18 20:50 by blueyed, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (3)
msg340512 - (view) Author: daniel hahler (blueyed) * Date: 2019-04-18 20:50
Currently Pdb.user_exception does not store the traceback in "user_exception", but only passes it to `interaction`:


    def user_exception(self, frame, exc_info):
        """This function is called if an exception occurs,
        but only if we are to stop at or just below this level."""
        if self._wait_for_mainpyfile:
            return
        exc_type, exc_value, exc_traceback = exc_info
        frame.f_locals['__exception__'] = exc_type, exc_value
        …
        self.interaction(frame, exc_traceback)

I think it would be useful to have the whole exception info at hand in the debugger (via the frame locals) directly.


If backward compatible is important it should use a new name for this maybe (`__excinfo__`), i.e. if current code would assume `__exception__` to be of length 2 only.
But on the other hand this only affects extensions to the debugger, and not "real" programs, and therefore backward compatibility is not really required here?

Currenly pdb extensions (e.g. pdbpp) can get it either by going up in the stack, or grabbing it via `interaction`, but this issue is mainly about making it available in plain pdb for the user to interact with.

Code ref: https://github.com/python/cpython/blob/e8113f51a8bdf33188ee30a1c038a298329e7bfa/Lib/pdb.py#L295-L301
msg395684 - (view) Author: Irit Katriel (iritkatriel) * (Python committer) Date: 2021-06-12 12:02
Isn't it enough that the traceback is available on exc_value.__traceback__?
msg396958 - (view) Author: Irit Katriel (iritkatriel) * (Python committer) Date: 2021-07-04 19:08
As mentioned above, I think this is redundant because the traceback is on exc_value.__traceback__. Closing as there was not reply to my question, but correct me if I misunderstood the issue.
History
Date User Action Args
2022-04-11 14:59:14adminsetgithub: 80844
2021-07-04 19:08:55iritkatrielsetstatus: open -> closed

messages: + msg396958
stage: resolved
2021-06-12 12:02:17iritkatrielsetnosy: + iritkatriel
messages: + msg395684
2019-04-18 20:50:11blueyedcreate