Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit fc70bfa

Browse files
committed
Reword docs for exception_handler in CallbackRegistry.
- Describe the signature of `exception_handler` in prose (the parameter name is not actually relevant, nor is the return value). - "Consuming" an exception is not a standard idiom. - Picklability is a detail here only relevant if you want to pickle the CallbackRegistry, and anyways it is generally true that setting an unpicklable attribute on an otherwise picklable object will make that object unpicklable. - The description of the default exception handler was incorrect.
1 parent 7c813db commit fc70bfa

File tree

1 file changed

+8
-14
lines changed

1 file changed

+8
-14
lines changed

lib/matplotlib/cbook/__init__.py

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -138,20 +138,14 @@ class CallbackRegistry:
138138
Parameters
139139
----------
140140
exception_handler : callable, optional
141-
If provided must have signature ::
142-
143-
def handler(exc: Exception) -> None:
144-
145-
If not None this function will be called with any `Exception`
146-
subclass raised by the callbacks in `CallbackRegistry.process`.
147-
The handler may either consume the exception or re-raise.
148-
149-
The callable must be pickle-able.
150-
151-
The default handler is ::
152-
153-
def h(exc):
154-
traceback.print_exc()
141+
If not None, *exception_handler* must be a function that takes an
142+
`Exception` as single parameter. It gets called with any `Exception`
143+
raised by the callbacks during `CallbackRegistry.process`, and may
144+
either re-raise the exception or handle it in another manner.
145+
146+
The default handler prints the exception (with `traceback.print_exc`) if
147+
an interactive event loop is running; it re-raises the exception if no
148+
interactive event loop is running.
155149
"""
156150

157151
# We maintain two mappings:

0 commit comments

Comments
 (0)