diff options
author | Victor Stinner <vstinner@redhat.com> | 2019-05-24 22:09:38 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-05-24 22:09:38 (GMT) |
commit | 6dbbe748e101a173b4cff8aada41e9313e287e0f (patch) | |
tree | b0361e58e666c57fd742d44b30c5bf72e98c090b /Doc | |
parent | a9f05d69ccbf3c75cdd604c25094282697789a62 (diff) | |
download | cpython-6dbbe748e101a173b4cff8aada41e9313e287e0f.zip cpython-6dbbe748e101a173b4cff8aada41e9313e287e0f.tar.gz cpython-6dbbe748e101a173b4cff8aada41e9313e287e0f.tar.bz2 |
bpo-36829: Document test.support.catch_unraisable_exception() (GH-13554)
catch_unraisable_exception() now also removes its 'unraisable'
attribute at the context manager exit.
Diffstat (limited to 'Doc')
-rw-r--r-- | Doc/library/test.rst | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/Doc/library/test.rst b/Doc/library/test.rst index 054521d..b7a2595 100644 --- a/Doc/library/test.rst +++ b/Doc/library/test.rst @@ -1081,6 +1081,26 @@ The :mod:`test.support` module defines the following functions: :exc:`PermissionError` is raised. +.. function:: catch_unraisable_exception() + + Context manager catching unraisable exception using + :func:`sys.unraisablehook`. + + Usage:: + + with support.catch_unraisable_exception() as cm: + # code creating an "unraisable exception" + ... + + # check the unraisable exception: use cm.unraisable + ... + + # cm.unraisable attribute no longer exists at this point + # (to break a reference cycle) + + .. versionadded:: 3.8 + + .. function:: find_unused_port(family=socket.AF_INET, socktype=socket.SOCK_STREAM) Returns an unused port that should be suitable for binding. This is |