Print lines of code from the current stack frame
(self, arg)
| 917 | ) |
| 918 | |
| 919 | def do_list(self, arg): |
| 920 | """Print lines of code from the current stack frame""" |
| 921 | self.lastcmd = "list" |
| 922 | last = None |
| 923 | if arg and arg != ".": |
| 924 | try: |
| 925 | x = eval(arg, {}, {}) |
| 926 | if type(x) == type(()): |
| 927 | first, last = x # type: ignore[misc] |
| 928 | first = int(first) # type: ignore[call-overload] |
| 929 | last = int(last) # type: ignore[call-overload] |
| 930 | if last < first: |
| 931 | # Assume it's a count |
| 932 | last = first + last |
| 933 | else: |
| 934 | first = max(1, int(x) - 5) |
| 935 | except: |
| 936 | print("*** Error in argument:", repr(arg), file=self.stdout) |
| 937 | return |
| 938 | elif self.lineno is None or arg == ".": |
| 939 | assert self.curframe is not None |
| 940 | first = max(1, self.curframe.f_lineno - 5) |
| 941 | else: |
| 942 | first = self.lineno + 1 |
| 943 | if last is None: |
| 944 | last = first + 10 |
| 945 | assert self.curframe is not None |
| 946 | self.print_list_lines(self.curframe.f_code.co_filename, first, last) |
| 947 | |
| 948 | lineno = first |
| 949 | filename = self.curframe.f_code.co_filename |
| 950 | self.shell.hooks.synchronize_with_editor(filename, lineno, 0) |
| 951 | |
| 952 | do_l = do_list |
| 953 |
nothing calls this directly
no test coverage detected