File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2828
2929import bdb
3030import functools
31+ import inspect
3132import linecache
3233import sys
3334
@@ -513,6 +514,28 @@ def do_list(self, arg):
513514
514515 do_l = do_list
515516
517+ def getsourcelines (self , obj ):
518+ lines , lineno = inspect .findsource (obj )
519+ if inspect .isframe (obj ) and obj .f_globals is obj .f_locals :
520+ # must be a module frame: do not try to cut a block out of it
521+ return lines , 1
522+ elif inspect .ismodule (obj ):
523+ return lines , 1
524+ return inspect .getblock (lines [lineno :]), lineno + 1
525+
526+ def do_longlist (self , arg ):
527+ self .lastcmd = 'longlist'
528+ filename = self .curframe .f_code .co_filename
529+ breaklist = self .get_file_breaks (filename )
530+ try :
531+ lines , lineno = self .getsourcelines (self .curframe )
532+ except OSError as err :
533+ self .error (err )
534+ return
535+ last = lineno + len (lines )
536+ self .print_list_lines (self .curframe .f_code .co_filename , lineno , last )
537+ do_ll = do_longlist
538+
516539 def do_pdef (self , arg ):
517540 """Print the call signature for any callable object.
518541
You can’t perform that action at this time.
0 commit comments