@@ -63,6 +63,7 @@ class ListCommand(DebuggerCommand):
6363 list foo.py:5 # List starting from line 5 of file foo.py
6464 list foo() # List starting from function foo
6565 list os.path:5 # List starting from line 5 of module os.path
66+ # Note: os.path should have been imported
6667 list os.path:5, 6 # list lines 5 and 6 of os.path
6768 list os.path:5, +1 # Same as above. +1 is an offset
6869 list os.path:5, 1 # Same as above, since 1 < 5.
@@ -93,7 +94,23 @@ def run(self, args):
9394 curframe = proc .curframe
9495 if filename is None :
9596 return
96- filename = pyficache .unmap_file (pyficache .resolve_name_to_path (filename ))
97+ resolved_name = pyficache .resolve_name_to_path (filename )
98+ if not osp .exists (resolved_name ):
99+ # See of resuled_filename is a module name:
100+ # START HERE with try: eval, except
101+ try :
102+ obj = self .proc .eval (filename , show_error = False )
103+ except Exception :
104+ self .errmsg (f"File { filename } not found" )
105+ return
106+ else :
107+ if inspect .ismodule (obj ):
108+ resolved_name = pyficache .resolve_name_to_path (obj .__file__ )
109+ else :
110+ self .errmsg (f"Can't use { obj } as a file-like object" )
111+ return
112+
113+ filename = pyficache .unmap_file (resolved_name )
97114 is_pyasm = filename .endswith (".pyasm" )
98115
99116 # We now have range information. Do the listing.
@@ -207,6 +224,10 @@ def doit(cmd, args):
207224 cmdproc .setup ()
208225 lcmd = ListCommand (cmdproc )
209226
227+ # Note: osp is defined abouve
228+ doit (lcmd , ['list' , "osp:1" ])
229+ # print('--' * 10)
230+
210231 print ("--" * 10 )
211232 # doit(lcmd, ['list'])
212233
0 commit comments