This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Avoid creating AttributeError exceptions in the debugger
Type: Stage: resolved
Components: Library (Lib) Versions: Python 3.11, Python 3.10, Python 3.9
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: blueyed, iritkatriel
Priority: normal Keywords: patch

Created on 2019-04-07 19:15 by blueyed, last changed 2022-04-11 14:59 by admin.

Pull Requests
URL Status Linked Edit
PR 4666 open blueyed, 2019-04-07 19:16
Messages (4)
msg339583 - (view) Author: daniel hahler (blueyed) * Date: 2019-04-07 19:15
pdb should try (hard) to avoid creating unnecessary exceptions, e.g. ``AttributeError`` when looking up commands, since this will show up in exception chains then (as "'Pdb' object has no attribute 'do_foo'").

See https://github.com/python/cpython/pull/4666 for an older PR in this regard.

My use case is to display the traceback for exceptions caused within/via Pdb.default(), to see more context when running code from pdb's prompt directly, where currently it would only display the exception itself.
msg401237 - (view) Author: Irit Katriel (iritkatriel) * (Python committer) Date: 2021-09-07 11:10
Closing as the bug is not clear and the OP is not responding to requests on the PR to clarify it. Please create a new issue if you are still seeing a problem.
msg401253 - (view) Author: daniel hahler (blueyed) * Date: 2021-09-07 12:22
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.)
msg401260 - (view) Author: Irit Katriel (iritkatriel) * (Python committer) Date: 2021-09-07 13:07
Reopened.
History
Date User Action Args
2022-04-11 14:59:13adminsetgithub: 80731
2021-09-07 13:07:17iritkatrielsetstatus: closed -> open
resolution: rejected ->
messages: + msg401260

versions: - Python 3.6, Python 3.7, Python 3.8
2021-09-07 12:22:04blueyedsetmessages: + msg401253
versions: + Python 3.6, Python 3.7, Python 3.8, Python 3.10, Python 3.11
2021-09-07 11:10:23iritkatrielsetstatus: open -> closed

nosy: + iritkatriel
messages: + msg401237

resolution: rejected
stage: patch review -> resolved
2019-04-07 19:16:02blueyedsetkeywords: + patch
stage: patch review
pull_requests: + pull_request12643
2019-04-07 19:15:47blueyedcreate