diff options
author | Daniel Hahler <git@thequod.de> | 2021-06-10 20:32:04 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-10 20:32:04 (GMT) |
commit | 6544b2532df82d137b71323445a07a6e29bcdec0 (patch) | |
tree | 82d643644f5274a19db30e8f0c10498d8b77b1ac /Lib/test/test_pdb.py | |
parent | 8a4f0850d75747af8c96ca0e7eef1f5c1abfba25 (diff) | |
download | cpython-6544b2532df82d137b71323445a07a6e29bcdec0.zip cpython-6544b2532df82d137b71323445a07a6e29bcdec0.tar.gz cpython-6544b2532df82d137b71323445a07a6e29bcdec0.tar.bz2 |
bpo-37022: Fix bug where pdb's do_p/do_pp commands swallow exceptions from repr (GH-18180)
Diffstat (limited to 'Lib/test/test_pdb.py')
-rw-r--r-- | Lib/test/test_pdb.py | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/Lib/test/test_pdb.py b/Lib/test/test_pdb.py index 08c0ffa..aa3035b 100644 --- a/Lib/test/test_pdb.py +++ b/Lib/test/test_pdb.py @@ -391,6 +391,34 @@ def test_pdb_breakpoints_preserved_across_interactive_sessions(): (Pdb) continue """ +def test_pdb_pp_repr_exc(): + """Test that do_p/do_pp do not swallow exceptions. + + >>> class BadRepr: + ... def __repr__(self): + ... raise Exception('repr_exc') + >>> obj = BadRepr() + + >>> def test_function(): + ... import pdb; pdb.Pdb(nosigint=True, readrc=False).set_trace() + + >>> with PdbTestInput([ # doctest: +NORMALIZE_WHITESPACE + ... 'p obj', + ... 'pp obj', + ... 'continue', + ... ]): + ... test_function() + --Return-- + > <doctest test.test_pdb.test_pdb_pp_repr_exc[2]>(2)test_function()->None + -> import pdb; pdb.Pdb(nosigint=True, readrc=False).set_trace() + (Pdb) p obj + *** Exception: repr_exc + (Pdb) pp obj + *** Exception: repr_exc + (Pdb) continue + """ + + def do_nothing(): pass |