From d927d9d4a6deb6fad60fa4fab0df8e4b0dba2634 Mon Sep 17 00:00:00 2001 From: Mark Shannon Date: Mon, 17 Jan 2022 16:22:49 +0000 Subject: [PATCH] Update PEP 669 specification to return current callback object when registering a new callback. (#2246) --- pep-0669.rst | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pep-0669.rst b/pep-0669.rst index a34cb311dad..ebef129c576 100644 --- a/pep-0669.rst +++ b/pep-0669.rst @@ -127,6 +127,8 @@ To register a callable for events call:: sys.monitoring.register_callback(event, func) +``register_callback`` returns the previously registered callback, or ``None``. + Functions can be unregistered by calling ``sys.monitoring.register_callback(event, None)``. @@ -192,7 +194,7 @@ Attributes of the ``sys.monitoring`` namespace * ``def set_events(event_set: Event)->None`` * ``def get_local_events(code: CodeType)->Event`` * ``def set_local_events(code: CodeType, event_set: Event)->None`` -* ``def register_callback(event: Event, func: Callable)->None`` +* ``def register_callback(event: Event, func: Callable)->Optional[Callable]`` * ``def insert_marker(code: CodeType, offset: Event, marker_id=0: range(256))->None`` * ``def remove_marker(code: CodeType, offset: Event)->None``