Cut off a traceback at the function with the given name. The func_name's frame is excluded. Args: tb: traceback object, as returned by sys.exc_info()[2] func_name: function name Returns: Reduced traceback.
(tb, func_name)
| 22 | |
| 23 | |
| 24 | def cut_traceback(tb, func_name): |
| 25 | """ |
| 26 | Cut off a traceback at the function with the given name. |
| 27 | The func_name's frame is excluded. |
| 28 | |
| 29 | Args: |
| 30 | tb: traceback object, as returned by sys.exc_info()[2] |
| 31 | func_name: function name |
| 32 | |
| 33 | Returns: |
| 34 | Reduced traceback. |
| 35 | """ |
| 36 | tb_orig = tb |
| 37 | for _, _, fname, _ in traceback.extract_tb(tb): |
| 38 | tb = tb.tb_next |
| 39 | if fname == func_name: |
| 40 | break |
| 41 | return tb or tb_orig |
| 42 | |
| 43 | |
| 44 | @contextlib.contextmanager |
no outgoing calls
no test coverage detected
searching dependent graphs…