Show More
@@ -28,6 +28,7 b' from __future__ import print_function' | |||||
28 |
|
28 | |||
29 | import bdb |
|
29 | import bdb | |
30 | import functools |
|
30 | import functools | |
|
31 | import inspect | |||
31 | import linecache |
|
32 | import linecache | |
32 | import sys |
|
33 | import sys | |
33 |
|
34 | |||
@@ -513,6 +514,28 b' class Pdb(OldPdb):' | |||||
513 |
|
514 | |||
514 | do_l = do_list |
|
515 | do_l = do_list | |
515 |
|
516 | |||
|
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 | ||||
516 | def do_pdef(self, arg): |
|
539 | def do_pdef(self, arg): | |
517 | """Print the call signature for any callable object. |
|
540 | """Print the call signature for any callable object. | |
518 |
|
541 |
General Comments 0
You need to be logged in to leave comments.
Login now