@@ -1915,6 +1915,52 @@ def test_issue42383(self):
19151915 self .assertEqual (stdout .split ('\n ' )[6 ].rstrip ('\r ' ), expected )
19161916
19171917
1918+ def test_gh_93696_frozen_list (self ):
1919+ frozen_src = """
1920+ def func():
1921+ x = "Sentinel string for gh-93696"
1922+ print(x)
1923+ """
1924+ host_program = """
1925+ import os
1926+ import sys
1927+
1928+ def _create_fake_frozen_module():
1929+ with open('gh93696.py') as f:
1930+ src = f.read()
1931+
1932+ # this function has a co_filename as if it were in a frozen module
1933+ dummy_mod = compile(src, "<frozen gh93696>", "exec")
1934+ func_code = dummy_mod.co_consts[0]
1935+
1936+ mod = type(sys)("gh93696")
1937+ mod.func = type(lambda: None)(func_code, mod.__dict__)
1938+ mod.__file__ = 'gh93696.py'
1939+
1940+ return mod
1941+
1942+ mod = _create_fake_frozen_module()
1943+ mod.func()
1944+ """
1945+ commands = """
1946+ break 20
1947+ continue
1948+ step
1949+ list
1950+ quit
1951+ """
1952+ with open ('gh93696.py' , 'w' ) as f :
1953+ f .write (textwrap .dedent (frozen_src ))
1954+
1955+ with open ('gh93696_host.py' , 'w' ) as f :
1956+ f .write (textwrap .dedent (host_program ))
1957+
1958+ self .addCleanup (os_helper .unlink , 'gh93696.py' )
1959+ self .addCleanup (os_helper .unlink , 'gh93696_host.py' )
1960+ stdout , stderr = self ._run_pdb (["gh93696_host.py" ], commands )
1961+ # verify that pdb found the source of the "frozen" function
1962+ self .assertIn ('x = "Sentinel string for gh-93696"' , stdout , "Sentinel statement not found" )
1963+
19181964class ChecklineTests (unittest .TestCase ):
19191965 def setUp (self ):
19201966 linecache .clearcache () # Pdb.checkline() uses linecache.getline()
0 commit comments