You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
can't step through _frozen_importlib/importlib._bootstrap using pdb #60115
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.
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.
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).
changed the title [-]can't step through _frozen_importlib/importlib._bootstrap using gdb[/-][+]can't step through _frozen_importlib/importlib._bootstrap using pdb[/+]on Jan 29, 2020
Activity
exarkun commentedon 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.
ericsnowcurrently commentedon 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 commentedon 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)::
Which are accurate line counts::
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).
[-]Debugging import problems is hard[/-][+]can't step through _frozen_importlib/importlib._bootstrap using gdb[/+][-]can't step through _frozen_importlib/importlib._bootstrap using gdb[/-][+]can't step through _frozen_importlib/importlib._bootstrap using pdb[/+]ericsnowcurrently commentedon Jul 21, 2022
This should mostly be resolved in 3.10. See issue gh-65935 (and PR gh-28656).
gsnedders commentedon Jan 23, 2025
For those like me who stumble across this, on 3.13:
So while it isn't actually printing the current line during execution,
listdoes manage to get the source.gh-60115: Support frozen modules for linecache.getline() (#131638)