Return a string with information about a stack entry. The stack entry frame_lineno is a (frame, lineno) tuple. The return string contains the canonical filename, the function name or ' ', the input arguments, the return value, and the line of code (if it
(self, frame_lineno, lprefix=': ')
| 549 | return stack, i |
| 550 | |
| 551 | def format_stack_entry(self, frame_lineno, lprefix=': '): |
| 552 | """Return a string with information about a stack entry. |
| 553 | |
| 554 | The stack entry frame_lineno is a (frame, lineno) tuple. The |
| 555 | return string contains the canonical filename, the function name |
| 556 | or '<lambda>', the input arguments, the return value, and the |
| 557 | line of code (if it exists). |
| 558 | |
| 559 | """ |
| 560 | import linecache, reprlib |
| 561 | frame, lineno = frame_lineno |
| 562 | filename = self.canonic(frame.f_code.co_filename) |
| 563 | s = '%s(%r)' % (filename, lineno) |
| 564 | if frame.f_code.co_name: |
| 565 | s += frame.f_code.co_name |
| 566 | else: |
| 567 | s += "<lambda>" |
| 568 | s += '()' |
| 569 | if '__return__' in frame.f_locals: |
| 570 | rv = frame.f_locals['__return__'] |
| 571 | s += '->' |
| 572 | s += reprlib.repr(rv) |
| 573 | if lineno is not None: |
| 574 | line = linecache.getline(filename, lineno, frame.f_globals) |
| 575 | if line: |
| 576 | s += lprefix + line.strip() |
| 577 | else: |
| 578 | s += f'{lprefix}Warning: lineno is None' |
| 579 | return s |
| 580 | |
| 581 | # The following methods can be called by clients to use |
| 582 | # a debugger to debug a statement or an expression. |
no test coverage detected