gh-93696: Locate frozen module source with __file__ (#93697)

Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
This commit is contained in:
James Gerity 2022-10-25 09:22:53 -04:00 committed by GitHub
parent dd13b23e49
commit d91de288e7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 53 additions and 0 deletions

View file

@ -1332,6 +1332,12 @@ class Pdb(bdb.Bdb, cmd.Cmd):
if last is None:
last = first + 10
filename = self.curframe.f_code.co_filename
# gh-93696: stdlib frozen modules provide a useful __file__
# this workaround can be removed with the closure of gh-89815
if filename.startswith("<frozen"):
tmp = self.curframe.f_globals.get("__file__")
if isinstance(tmp, str):
filename = tmp
breaklist = self.get_file_breaks(filename)
try:
lines = linecache.getlines(filename, self.curframe.f_globals)