@@ -68,10 +68,34 @@ Module contents
6868 signal (SIG*), handler (:const: `SIG_DFL `, :const: `SIG_IGN `) and sigmask
6969 (:const: `SIG_BLOCK `, :const: `SIG_UNBLOCK `, :const: `SIG_SETMASK `)
7070 related constants listed below were turned into
71- :class: `enums <enum.IntEnum> `.
71+ :class: `enums <enum.IntEnum> ` ( :class: ` Signals `, :class: ` Handlers ` and :class: ` Sigmasks ` respectively) .
7272 :func: `getsignal `, :func: `pthread_sigmask `, :func: `sigpending ` and
7373 :func: `sigwait ` functions return human-readable
74- :class: `enums <enum.IntEnum> `.
74+ :class: `enums <enum.IntEnum> ` as :class: `Signals ` objects.
75+
76+
77+ The signal module defines three enums:
78+
79+ .. class :: Signals
80+
81+ :class: `enum.IntEnum ` collection of SIG* constants and the CTRL_* constants.
82+
83+ .. versionadded :: 3.5
84+
85+ .. class :: Handlers
86+
87+ :class: `enum.IntEnum ` collection the constants :const: `SIG_DFL ` and :const: `SIG_IGN `.
88+
89+ .. versionadded :: 3.5
90+
91+ .. class :: Sigmasks
92+
93+ :class: `enum.IntEnum ` collection the constants :const: `SIG_BLOCK `, :const: `SIG_UNBLOCK ` and :const: `SIG_SETMASK `.
94+
95+ Availability: Unix. See the man page :manpage: `sigprocmask(3)` and
96+ :manpage: `pthread_sigmask(3)` for further information.
97+
98+ .. versionadded :: 3.5
7599
76100
77101The variables defined in the :mod: `signal ` module are:
@@ -618,8 +642,8 @@ The :mod:`signal` module defines the following functions:
618642
619643.. _signal-example :
620644
621- Example
622- -------
645+ Examples
646+ --------
623647
624648Here is a minimal example program. It uses the :func: `alarm ` function to limit
625649the time spent waiting to open a file; this is useful if the file is for a
@@ -631,7 +655,8 @@ be sent, and the handler raises an exception. ::
631655 import signal, os
632656
633657 def handler(signum, frame):
634- print('Signal handler called with signal', signum)
658+ signame = signal.Signals(signum).name
659+ print(f'Signal handler called with signal {signame} ({signum})')
635660 raise OSError("Couldn't open device!")
636661
637662 # Set the signal handler and a 5-second alarm
0 commit comments