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 <greg@krypto.org>
This commit is contained in:
ram vikram singh 2022-11-14 01:11:23 +05:30 committed by GitHub
parent 343eb0f94b
commit 88385b8564
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 9 deletions

View File

@ -362,9 +362,9 @@ The :mod:`signal` module defines the following functions:
.. function:: strsignal(signalnum) .. function:: strsignal(signalnum)
Return the system description of the signal *signalnum*, such as Returns the description of signal *signalnum*, such as "Interrupt"
"Interrupt", "Segmentation fault", etc. Returns :const:`None` if the signal for :const:`SIGINT`. Returns :const:`None` if *signalnum* has no
is not recognized. description. Raises :exc:`ValueError` if *signalnum* is invalid.
.. versionadded:: 3.8 .. versionadded:: 3.8

View File

@ -211,8 +211,9 @@ PyDoc_STRVAR(signal_strsignal__doc__,
"\n" "\n"
"Return the system description of the given signal.\n" "Return the system description of the given signal.\n"
"\n" "\n"
"The return values can be such as \"Interrupt\", \"Segmentation fault\", etc.\n" "Returns the description of signal *signalnum*, such as \"Interrupt\"\n"
"Returns None if the signal is not recognized."); "for :const:`SIGINT`. Returns :const:`None` if *signalnum* has no\n"
"description. Raises :exc:`ValueError` if *signalnum* is invalid.");
#define SIGNAL_STRSIGNAL_METHODDEF \ #define SIGNAL_STRSIGNAL_METHODDEF \
{"strsignal", (PyCFunction)signal_strsignal, METH_O, signal_strsignal__doc__}, {"strsignal", (PyCFunction)signal_strsignal, METH_O, signal_strsignal__doc__},
@ -704,4 +705,4 @@ exit:
#ifndef SIGNAL_PIDFD_SEND_SIGNAL_METHODDEF #ifndef SIGNAL_PIDFD_SEND_SIGNAL_METHODDEF
#define SIGNAL_PIDFD_SEND_SIGNAL_METHODDEF #define SIGNAL_PIDFD_SEND_SIGNAL_METHODDEF
#endif /* !defined(SIGNAL_PIDFD_SEND_SIGNAL_METHODDEF) */ #endif /* !defined(SIGNAL_PIDFD_SEND_SIGNAL_METHODDEF) */
/*[clinic end generated code: output=f2a3321b32b0637c input=a9049054013a1b77]*/ /*[clinic end generated code: output=2b54dc607f6e3146 input=a9049054013a1b77]*/

View File

@ -626,13 +626,14 @@ signal.strsignal
Return the system description of the given signal. Return the system description of the given signal.
The return values can be such as "Interrupt", "Segmentation fault", etc. Returns the description of signal *signalnum*, such as "Interrupt"
Returns None if the signal is not recognized. for :const:`SIGINT`. Returns :const:`None` if *signalnum* has no
description. Raises :exc:`ValueError` if *signalnum* is invalid.
[clinic start generated code]*/ [clinic start generated code]*/
static PyObject * static PyObject *
signal_strsignal_impl(PyObject *module, int signalnum) 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; const char *res;