Skip to content

Commit

Permalink
gh-98930: improve the docstring of signal.strsignal (#99290)
Browse files Browse the repository at this point in the history
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 <greg@krypto.org>
  • Loading branch information
ramvikrams and gpshead authored Nov 13, 2022
1 parent 343eb0f commit 88385b8
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
6 changes: 3 additions & 3 deletions Doc/library/signal.rst
Original file line number Diff line number Diff line change
Expand Up @@ -362,9 +362,9 @@ The :mod:`signal` module defines the following functions:

.. function:: strsignal(signalnum)

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

.. versionadded:: 3.8

Expand Down
7 changes: 4 additions & 3 deletions Modules/clinic/signalmodule.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions Modules/signalmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -626,13 +626,14 @@ signal.strsignal
Return the system description of the given signal.
The return values can be such as "Interrupt", "Segmentation fault", etc.
Returns None if the signal is not recognized.
Returns the description of signal *signalnum*, such as "Interrupt"
for :const:`SIGINT`. Returns :const:`None` if *signalnum* has no
description. Raises :exc:`ValueError` if *signalnum* is invalid.
[clinic start generated code]*/

static PyObject *
signal_strsignal_impl(PyObject *module, int signalnum)
/*[clinic end generated code: output=44e12e1e3b666261 input=b77914b03f856c74]*/
/*[clinic end generated code: output=44e12e1e3b666261 input=238b335847778bc0]*/
{
const char *res;

Expand Down

0 comments on commit 88385b8

Please sign in to comment.