Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions Doc/whatsnew/3.15.rst
Original file line number Diff line number Diff line change
Expand Up @@ -788,6 +788,15 @@ base64
(Contributed by Gregory P. Smith in :gh:`146311`.)


bdb
---

* :exc:`bdb.BdbQuit` is now a subclass of :exc:`BaseException`, instead of
:exc:`Exception`, to allow it to be used for cleanly exiting the debugger without
being accidentally caught by user code.
(Contributed by Tian Gao in :gh:`149337`.)


binascii
--------

Expand Down
2 changes: 1 addition & 1 deletion Lib/bdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
GENERATOR_AND_COROUTINE_FLAGS = CO_GENERATOR | CO_COROUTINE | CO_ASYNC_GENERATOR


class BdbQuit(Exception):
class BdbQuit(BaseException):
"""Exception to give up completely."""


Expand Down
9 changes: 9 additions & 0 deletions Lib/test/test_bdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -1237,6 +1237,15 @@ def test_format_stack_entry_no_lineno(self):
self.assertIn('Warning: lineno is None',
Bdb().format_stack_entry((sys._getframe(), None)))

def test_bdb_quit_base_exception(self):
# gh-149309
try:
raise _bdb.BdbQuit()
except Exception:
self.fail(f'BdbQuit should not be caught by Exception')
except BaseException:
pass


if __name__ == "__main__":
unittest.main()
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
:exc:`bdb.BdbQuit` is now a subclass of :exc:`BaseException`, instead of :exc:`Exception`, to allow it to be used for cleanly exiting the debugger without being accidentally caught by user code.
Loading