Files
typeshed/stdlib
Rebecca Turner 72f4057d81 Signal handler callables take int, not Signals (#5622)
The documentation for [`signal.signal`][1] points out that the current
annotation for signal handlers might be wrong (emphasis my own):

> The handler is called with two arguments: the signal **number** and the
> current stack frame (**`None` or** a frame object; for a description of frame
> objects, see the description in the type hierarchy or see the attribute
> descriptions in the `inspect` module).

And when we use them, we can see that the signal number is passed as an `int`,
not a `signal.Signals` member:

import signal

    def handler(signal_number, frame):
        print("In signal handler!")
        print("Signal number:", signal_number, type(signal_number))
        print("Stack frame:  ", frame, type(frame))

    # Set signal handler:
    signal.signal(signal.SIGHUP, handler)

    # Use it:
    signal.raise_signal(signal.SIGHUP)

Which prints:

    In signal handler!
    Signal number: 1 <class 'int'>
    Stack frame:   <frame at 0x7f804402abe0, file '<stdin>', line 12, code <module>> <class 'frame'>

[1]: https://docs.python.org/3/library/signal.html#signal.signal
2021-06-11 20:28:20 +03:00
..
2021-06-09 00:25:01 +02:00
2021-04-25 21:56:54 -07:00
2021-05-21 15:46:01 +02:00
2021-05-17 20:45:48 +02:00
2021-04-29 07:02:52 -07:00
2021-05-02 16:24:34 -07:00
2021-05-15 20:49:20 +03:00
2021-05-17 20:45:48 +02:00
2021-05-17 20:45:48 +02:00
2021-05-26 22:16:51 +02:00
2021-05-17 20:45:48 +02:00
2021-05-17 20:45:48 +02:00
2021-05-17 20:45:48 +02:00
2021-05-06 18:57:33 +03:00
2021-05-01 20:58:30 -07:00
2021-05-30 20:17:33 +02:00
2021-04-25 21:56:54 -07:00
2021-05-30 20:17:33 +02:00
2021-05-17 20:45:48 +02:00
2021-05-17 20:45:48 +02:00
2021-05-05 17:23:43 +03:00
2021-05-17 20:45:48 +02:00
2021-05-04 15:12:19 +03:00
2021-05-17 20:45:48 +02:00
2021-01-27 12:00:39 +00:00
2021-05-17 20:45:48 +02:00
2021-05-17 20:45:48 +02:00
2021-05-13 18:20:55 -07:00
2021-05-17 20:45:48 +02:00
2021-05-29 19:32:39 +02:00
2021-01-27 12:00:39 +00:00
2021-05-17 20:45:48 +02:00
2021-05-17 20:45:48 +02:00
2021-05-17 20:45:48 +02:00
2021-05-17 20:45:48 +02:00
2021-05-05 17:23:43 +03:00
2021-05-17 20:45:48 +02:00
2021-04-23 10:15:07 -07:00
2021-04-14 19:14:07 -07:00
2021-05-05 17:23:43 +03:00
2021-05-17 20:45:48 +02:00
2021-05-17 20:45:48 +02:00
2021-05-17 20:45:48 +02:00
2021-05-11 10:46:26 +02:00
2021-04-30 20:05:06 +02:00
2021-05-17 20:45:48 +02:00
2021-04-18 09:30:00 -07:00
2021-02-20 18:44:36 -08:00
2021-03-23 20:56:47 -07:00
2021-05-05 17:23:43 +03:00
2021-05-17 20:45:48 +02:00
2021-05-30 20:17:33 +02:00
2021-05-30 20:17:33 +02:00
2021-05-13 18:20:55 -07:00
2021-05-30 20:17:33 +02:00
2021-05-17 20:45:48 +02:00
2021-05-17 20:45:48 +02:00
2021-05-17 20:45:48 +02:00
2021-04-17 07:03:28 -07:00
2021-05-29 11:09:50 -07:00
2021-06-09 00:27:49 +03:00