Skip to content

Commit 88385b8

Browse files
ramvikramsgpshead
andauthored
gh-98930: improve the docstring of signal.strsignal (#99290)
Improves the docstring on signal.strsignal to make it explain when it returns a message, None, or when it raises ValueError. Closes #98930 Co-authored-by: Gregory P. Smith <[email protected]>
1 parent 343eb0f commit 88385b8

File tree

3 files changed

+11
-9
lines changed

3 files changed

+11
-9
lines changed

Doc/library/signal.rst

+3-3
Original file line numberDiff line numberDiff line change
@@ -362,9 +362,9 @@ The :mod:`signal` module defines the following functions:
362362

363363
.. function:: strsignal(signalnum)
364364

365-
Return the system description of the signal *signalnum*, such as
366-
"Interrupt", "Segmentation fault", etc. Returns :const:`None` if the signal
367-
is not recognized.
365+
Returns the description of signal *signalnum*, such as "Interrupt"
366+
for :const:`SIGINT`. Returns :const:`None` if *signalnum* has no
367+
description. Raises :exc:`ValueError` if *signalnum* is invalid.
368368

369369
.. versionadded:: 3.8
370370

Modules/clinic/signalmodule.c.h

+4-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Modules/signalmodule.c

+4-3
Original file line numberDiff line numberDiff line change
@@ -626,13 +626,14 @@ signal.strsignal
626626
627627
Return the system description of the given signal.
628628
629-
The return values can be such as "Interrupt", "Segmentation fault", etc.
630-
Returns None if the signal is not recognized.
629+
Returns the description of signal *signalnum*, such as "Interrupt"
630+
for :const:`SIGINT`. Returns :const:`None` if *signalnum* has no
631+
description. Raises :exc:`ValueError` if *signalnum* is invalid.
631632
[clinic start generated code]*/
632633

633634
static PyObject *
634635
signal_strsignal_impl(PyObject *module, int signalnum)
635-
/*[clinic end generated code: output=44e12e1e3b666261 input=b77914b03f856c74]*/
636+
/*[clinic end generated code: output=44e12e1e3b666261 input=238b335847778bc0]*/
636637
{
637638
const char *res;
638639

0 commit comments

Comments
 (0)