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

can't step through _frozen_importlib/importlib._bootstrap using pdb #60115

Open
exarkun mannequin opened this issue Sep 10, 2012 · 4 comments
Open

can't step through _frozen_importlib/importlib._bootstrap using pdb #60115

exarkun mannequin opened this issue Sep 10, 2012 · 4 comments
Labels
3.9 expert-importlib interpreter-core Interpreter core (Objects, Python, Grammar, and Parser dirs) stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@exarkun
Copy link
Mannequin

exarkun mannequin commented Sep 10, 2012

BPO 15911
Nosy @brettcannon, @ericsnowcurrently

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 = None
created_at = <Date 2012-09-10.19:30:36.307>
labels = ['interpreter-core', 'type-bug', 'library', '3.9']
title = "can't step through _frozen_importlib/importlib._bootstrap using pdb"
updated_at = <Date 2020-01-29.00:42:31.587>
user = 'https://bugs.python.org/exarkun'

bugs.python.org fields:

activity = <Date 2020-01-29.00:42:31.587>
actor = 'brett.cannon'
assignee = 'none'
closed = False
closed_date = None
closer = None
components = ['Interpreter Core', 'Library (Lib)']
creation = <Date 2012-09-10.19:30:36.307>
creator = 'exarkun'
dependencies = []
files = []
hgrepos = []
issue_num = 15911
keywords = []
message_count = 3.0
messages = ['170221', '170224', '170301']
nosy_count = 4.0
nosy_names = ['brett.cannon', 'exarkun', 'Arfrever', 'eric.snow']
pr_nums = []
priority = 'normal'
resolution = None
stage = 'test needed'
status = 'open'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue15911'
versions = ['Python 3.9']

@exarkun
Copy link
Mannequin Author

exarkun mannequin commented Sep 10, 2012

Debugging problems involving the frozen importlib._bootstrap is difficult, because the source for importlib._bootstrap is not available to pdb. The bootstrap code can be stepped through, but with only function names and line numbers available, not source lines.

The value of having importlib written in Python would be greatly enhanced if it were more like a regular Python module that, eg, pdb could display source lines from.

@exarkun exarkun mannequin added interpreter-core Interpreter core (Objects, Python, Grammar, and Parser dirs) stdlib Python modules in the Lib dir labels Sep 10, 2012
@ericsnowcurrently
Copy link
Member

ericsnowcurrently commented Sep 10, 2012

This comes back to bpo-14657, which addressed the frozen vs. non-frozen copies of importlib. It sounds like one useful solution for your situation would be for _frozen_importlib to be used only long enough for bootstrap purposes. This was discussed in that other issue.

@brettcannon
Copy link
Member

brettcannon commented Sep 11, 2012

I'm going to guess this is a shortcoming of pdb when it comes to frozen modules as I can get to the source using inspect (which pdb leans on)::

>>> len(inspect.findsource(_frozen_importlib)[0])
1761
>>> len(inspect.findsource(importlib._bootstrap)[0])
1761

Which are accurate line counts::

$ wc Lib/importlib/_bootstrap.py 
 1761  6236 62517 Lib/importlib/_bootstrap.py

So why gdb can't output the source line when it has the line number of the file I don't know when it can already get access to the source without issue.

And yes, debugging imports are hard. =) Still, it's better than before as you can easily toss in a print statement or two and then just regenerate the frozen object. But I do agree it would be nice to get gdb to play along with the whole situation (and thus the title change for this bug).

@brettcannon brettcannon changed the title Debugging import problems is hard can't step through _frozen_importlib/importlib._bootstrap using gdb Sep 11, 2012
@brettcannon brettcannon added the type-bug An unexpected behavior, bug, or error label Sep 11, 2012
@brettcannon brettcannon changed the title can't step through _frozen_importlib/importlib._bootstrap using gdb can't step through _frozen_importlib/importlib._bootstrap using pdb Jan 29, 2020
@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
@ericsnowcurrently
Copy link
Member

ericsnowcurrently commented Jul 21, 2022

This should mostly be resolved in 3.10. See issue gh-65935 (and PR gh-28656).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.9 expert-importlib interpreter-core Interpreter core (Objects, Python, Grammar, and Parser dirs) stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

3 participants