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

pdb: store whole exception information in locals (via user_exception) #80844

Closed
blueyed mannequin opened this issue Apr 18, 2019 · 3 comments
Closed

pdb: store whole exception information in locals (via user_exception) #80844

blueyed mannequin opened this issue Apr 18, 2019 · 3 comments
Labels
3.9 only security fixes stdlib Python modules in the Lib dir

Comments

@blueyed
Copy link
Mannequin

blueyed mannequin commented Apr 18, 2019

BPO 36663
Nosy @blueyed, @iritkatriel

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = <Date 2021-07-04.19:08:55.010>
created_at = <Date 2019-04-18.20:50:11.513>
labels = ['library', '3.9']
title = 'pdb: store whole exception information in locals (via user_exception)'
updated_at = <Date 2021-07-04.19:08:55.009>
user = 'https://github.com/blueyed'

bugs.python.org fields:

activity = <Date 2021-07-04.19:08:55.009>
actor = 'iritkatriel'
assignee = 'none'
closed = True
closed_date = <Date 2021-07-04.19:08:55.010>
closer = 'iritkatriel'
components = ['Library (Lib)']
creation = <Date 2019-04-18.20:50:11.513>
creator = 'blueyed'
dependencies = []
files = []
hgrepos = []
issue_num = 36663
keywords = []
message_count = 3.0
messages = ['340512', '395684', '396958']
nosy_count = 2.0
nosy_names = ['blueyed', 'iritkatriel']
pr_nums = []
priority = 'normal'
resolution = None
stage = 'resolved'
status = 'closed'
superseder = None
type = None
url = 'https://bugs.python.org/issue36663'
versions = ['Python 3.9']

@blueyed
Copy link
Mannequin Author

blueyed mannequin commented Apr 18, 2019

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_valueself.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:

cpython/Lib/pdb.py

Lines 295 to 301 in e8113f5

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

@blueyed blueyed mannequin added 3.9 only security fixes stdlib Python modules in the Lib dir labels Apr 18, 2019
@iritkatriel
Copy link
Member

Isn't it enough that the traceback is available on exc_value.__traceback__?

@iritkatriel
Copy link
Member

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.

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.9 only security fixes stdlib Python modules in the Lib dir
Projects
None yet
Development

No branches or pull requests

1 participant