Context manager to ensure proper cleaning of exceptions references When given a chained exception instead of a traceback, pdb may hold references to many objects which may leak memory. We use this context manager to make sure everything is properly cl
(self, exceptions)
| 471 | |
| 472 | @contextmanager |
| 473 | def _hold_exceptions(self, exceptions): |
| 474 | """ |
| 475 | Context manager to ensure proper cleaning of exceptions references |
| 476 | When given a chained exception instead of a traceback, |
| 477 | pdb may hold references to many objects which may leak memory. |
| 478 | We use this context manager to make sure everything is properly cleaned |
| 479 | """ |
| 480 | try: |
| 481 | self._chained_exceptions = exceptions |
| 482 | self._chained_exception_index = len(exceptions) - 1 |
| 483 | yield |
| 484 | finally: |
| 485 | # we can't put those in forget as otherwise they would |
| 486 | # be cleared on exception change |
| 487 | self._chained_exceptions = tuple() |
| 488 | self._chained_exception_index = 0 |
| 489 | |
| 490 | def do_exceptions(self, arg): |
| 491 | """exceptions [number] |