python: Accept Optional[FrameType] in signal handlers.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg
2021-12-22 21:53:42 -08:00
committed by Tim Abbott
parent 7a9074ecfd
commit 702ce071f4
3 changed files with 9 additions and 7 deletions

View File

@@ -20,12 +20,13 @@ logger = logging.getLogger("zulip.debug")
# (that link also points to code for an interactive remote debugger
# setup, which we might want if we move Tornado to run in a daemon
# rather than via screen).
def interactive_debug(sig: int, frame: FrameType) -> None:
def interactive_debug(sig: int, frame: Optional[FrameType]) -> None:
"""Interrupt running process, and provide a python prompt for
interactive debugging."""
d = {"_frame": frame} # Allow access to frame object.
d.update(frame.f_globals) # Unless shadowed by global
d.update(frame.f_locals)
if frame is not None:
d.update(frame.f_globals) # Unless shadowed by global
d.update(frame.f_locals)
message = "Signal received : entering python shell.\nTraceback:\n"
message += "".join(traceback.format_stack(frame))