| 1623 | return None |
| 1624 | |
| 1625 | def _run(self, target: Union[_ModuleTarget, _ScriptTarget]): |
| 1626 | # When bdb sets tracing, a number of call and line events happen |
| 1627 | # BEFORE debugger even reaches user's code (and the exact sequence of |
| 1628 | # events depends on python version). Take special measures to |
| 1629 | # avoid stopping before reaching the main script (see user_line and |
| 1630 | # user_call for details). |
| 1631 | self._wait_for_mainpyfile = True |
| 1632 | self._user_requested_quit = False |
| 1633 | |
| 1634 | self.mainpyfile = self.canonic(target.filename) |
| 1635 | |
| 1636 | # The target has to run in __main__ namespace (or imports from |
| 1637 | # __main__ will break). Clear __main__ and replace with |
| 1638 | # the target namespace. |
| 1639 | import __main__ |
| 1640 | __main__.__dict__.clear() |
| 1641 | __main__.__dict__.update(target.namespace) |
| 1642 | |
| 1643 | self.run(target.code) |
| 1644 | |
| 1645 | def _format_exc(self, exc: BaseException): |
| 1646 | return traceback.format_exception_only(exc)[-1].strip() |