[issue36550] Avoid creating AttributeError exceptions in the debugger
daniel hahler
report at bugs.python.org
Tue Sep 7 08:22:04 EDT 2021
daniel hahler <python-bugs at thequod.de> added the comment:
Given code like the following the try/except handling of Pdb (via `Cmd.onecmd`, see https://github.com/python/cpython/pull/4666) will mess with `sys.exc_info()`, which could be avoided:
```
try:
raise ValueError()
except Exception as exc:
e = exc
__import__('pdb').set_trace()
```
```
% ./python t_issue36550.py
--Return--
> …/t_issue36550.py(5)<module>()->None
-> __import__('pdb').set_trace()
(Pdb) import sys; sys.exc_info()
(<class 'AttributeError'>, AttributeError("'Pdb' object has no attribute 'do_import'"), <traceback object at 0x7f92d2782500>)
```
The initial / better motivation was described in the original issue: with pdb++/pdbpp I want to display tracebacks/errors with errors that might occur via Pdb's prompt, where this then showed up as interfering with it.
(Sorry for not responding on https://github.com/python/cpython/pull/4666 earlier, but I think it is only part of this issue, and therefore it should not get closed, and also creating a new one instead does not sound useful to me, so please consider to re-open it instead.)
----------
versions: +Python 3.10, Python 3.11, Python 3.6, Python 3.7, Python 3.8
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue36550>
_______________________________________
More information about the Python-bugs-list
mailing list