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

slightly easier way to debug from the exception handler #41471

Closed
leorochael mannequin opened this issue Jan 20, 2005 · 5 comments
Closed

slightly easier way to debug from the exception handler #41471

leorochael mannequin opened this issue Jan 20, 2005 · 5 comments
Assignees
Labels
stdlib Python modules in the Lib dir type-feature A feature request or enhancement

Comments

@leorochael
Copy link
Mannequin

leorochael mannequin commented Jan 20, 2005

BPO 1106316
Nosy @facundobatista, @etrepum

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 = 'https://github.com/facundobatista'
closed_at = <Date 2008-03-08.16:51:10.237>
created_at = <Date 2005-01-20.22:06:51.000>
labels = ['type-feature', 'library']
title = 'slightly easier way to debug from the exception handler'
updated_at = <Date 2008-03-08.16:51:10.236>
user = 'https://bugs.python.org/leorochael'

bugs.python.org fields:

activity = <Date 2008-03-08.16:51:10.236>
actor = 'facundobatista'
assignee = 'facundobatista'
closed = True
closed_date = <Date 2008-03-08.16:51:10.237>
closer = 'facundobatista'
components = ['Library (Lib)']
creation = <Date 2005-01-20.22:06:51.000>
creator = 'leorochael'
dependencies = []
files = []
hgrepos = []
issue_num = 1106316
keywords = []
message_count = 5.0
messages = ['54351', '54352', '54353', '63062', '63404']
nosy_count = 3.0
nosy_names = ['facundobatista', 'leorochael', 'bob.ippolito']
pr_nums = []
priority = 'normal'
resolution = 'accepted'
stage = None
status = 'closed'
superseder = None
type = 'enhancement'
url = 'https://bugs.python.org/issue1106316'
versions = []

@leorochael
Copy link
Mannequin Author

leorochael mannequin commented Jan 20, 2005

When interactively developing/debugging a program it'd
be nice if we could throw the user into the pdb prompt
straight from the exception handler.

Currently, pdb.pm() only works outside of the exception
handler, after "sys.last_traceback" has already been
set, which doesn't happen inside the "except:" clause.
The alternative is to use:

try:
something...
except:
import sys, pdb
pdb.post_mortem(sys.exc_info()[2])

I propose, as a convenience to the programmer, that the
first parameter to pdb.post_mortem() be made optional,
defaulting to None. In this case, it'd automatically
use the value of sys.exc_info()[2] in place of it's
otherwise mandatory first parameter. The example above
would be reduced to:

try:
something...
except:
import pdb;pdb.post_mortem()

alternatively, we could make it so that if
"sys.last_traceback" is not set "pdb.pm()" would pick
up sys.exc_info()[2] instead...

@leorochael leorochael mannequin added stdlib Python modules in the Lib dir type-feature A feature request or enhancement labels Jan 20, 2005
@etrepum
Copy link
Mannequin

etrepum mannequin commented Jan 20, 2005

Logged In: YES
user_id=139309

Why put this in pdb.post_mortem() if we can just put it in pdb.pm()?
pdb.pm() seems to already be for this purpose (except it currently only
works from the interactive interpreter as you mention).

@leorochael
Copy link
Mannequin Author

leorochael mannequin commented Jan 21, 2005

Logged In: YES
user_id=200267

I don't have any particular reason to prefer post_mortem()
to pm().

The knowledgeable Python maintainers surely are better
equiped than I am to know if pm() looking beyond
sys.last_traceback is a worse break of assumptions than
post_mortem() having it's only parameter being optional or
the other way around :-)

@facundobatista
Copy link
Member

If there's no objections, I'd make the traceback parameter optional in
the post_mortem method, making it default to sys.exc_info()[2].

Thanks!

@facundobatista
Copy link
Member

Added this functionality in r61312.

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stdlib Python modules in the Lib dir type-feature A feature request or enhancement
Projects
None yet
Development

No branches or pull requests

1 participant