(exc, tbs=None)
| 563 | |
| 564 | |
| 565 | def leaf_generator(exc, tbs=None): |
| 566 | if tbs is None: |
| 567 | tbs = [] |
| 568 | tbs.append(exc.__traceback__) |
| 569 | if isinstance(exc, BaseExceptionGroup): |
| 570 | for e in exc.exceptions: |
| 571 | yield from leaf_generator(e, tbs) |
| 572 | else: |
| 573 | # exc is a leaf exception and its traceback |
| 574 | # is the concatenation of the traceback |
| 575 | # segments in tbs |
| 576 | yield exc, tbs |
| 577 | tbs.pop() |
| 578 | |
| 579 | |
| 580 | class LeafGeneratorTest(unittest.TestCase): |
no test coverage detected
searching dependent graphs…