-
-
Notifications
You must be signed in to change notification settings - Fork 31k
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 cannot find source code for frozen stdlib modules #93696
Comments
Likely duplicate of #60115 |
Definitely related inasmuch as # repro2.py
import os.path
os.path.basename("/foo/bar/baz.py") # implemented in Python With Python 3.10:
With Python 3.11:
|
Pinging this issue per the devguide in the hopes of getting review on the PR, which has been open for a little while. I understand if things are too busy for review because of the release issues with 3.11, though! |
I get the same behavior as in the initial report against the current tip of
The |
Ah, thanks for checking. I missed that pdb wasn't using |
Yea, I'm not entirely sure what all goes into fixing the |
Yeah, it may be worth adding the stopgap fix in the meantime. |
FYI I am looking into this. I'll probably make deepfreeze generate the correct |
Co-authored-by: Kumar Aditya <[email protected]>
…3697) Co-authored-by: Kumar Aditya <[email protected]> (cherry picked from commit d91de28) Co-authored-by: James Gerity <[email protected]>
…3697) Co-authored-by: Kumar Aditya <[email protected]> (cherry picked from commit d91de28) Co-authored-by: James Gerity <[email protected]>
Co-authored-by: Kumar Aditya <[email protected]> (cherry picked from commit d91de28) Co-authored-by: James Gerity <[email protected]>
Co-authored-by: Kumar Aditya <[email protected]> (cherry picked from commit d91de28) Co-authored-by: James Gerity <[email protected]>
I'm adding this here in case anyone has to debug an older version of python and you still need This is an example of how to make the source lines available for import linecache
getline_original = linecache.getline
def getline_patched(filename, lineno, module_globals=None):
if filename == '<frozen importlib._bootstrap>':
filename = '/usr/lib/python3.9/importlib/_bootstrap.py'
return getline_original(filename, lineno, module_globals)
linecache.getline = getline_patched I also found this, but it didn't work for me; hence the code above. |
That workaround looks reasonable to me. I would suggest that users could replace the hard-coded |
I completely agree with you @SnoopJ, the associated PR is indeed the permanent solution. 🏆 In my situation, I had to work on a legacy system, and recompiling/changing the filesystem was not an option available to me at the time. 🥲 |
Bug report
Context: this issue came out of a discussion in #python on the Libera.chat IRC network, where a user wanted to peek into
importlib._bootstrap
withpdb
while chasing a bug.pdb
is capable of stepping into function calls into frozen modules, but thelist
command cannot locate the source code necessary to display the source being stepped through.Note that executing
source importlib._bootstrap
from the frame that calls into this module does successfully locate the source, but this isn't very useful to a user ofpdb
.I believe that bringing the frame's
co_filename
into agreement with the module's__file__
would fix this issue without changes topdb
(see #89815), but thought it would be good to track the issue withpdb
in a separate ticket since that fix is more nuanced and I think I have an interim patch for the debugger.Your environment
The text was updated successfully, but these errors were encountered: