Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3dbb406

Browse files
committed
Document Pyerr_Warn().
1 parent 1378c32 commit 3dbb406

1 file changed

Lines changed: 34 additions & 0 deletions

File tree

Doc/api/api.tex

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -945,6 +945,40 @@ \chapter{Exception Handling \label{exceptionHandling}}
945945
argument. It is mostly for internal use.
946946
\end{cfuncdesc}
947947

948+
\begin{cfuncdesc}{int}{PyErr_Warn}{PyObject *category, char *message}
949+
Issue a warning message. The \var{category} argument is a warning
950+
category (see below) or NULL; the \var{message} argument is a message
951+
string.
952+
953+
This function normally prints a warning message to \var{sys.stderr};
954+
however, it is also possible that the user has specified that warnings
955+
are to be turned into errors, and in that case this will raise an
956+
exception. It is also possible that the function raises an exception
957+
because of a problem with the warning machinery (the implementation
958+
imports the \module{warnings} module to do the heavy lifting). The
959+
return value is \code{0} if no exception is raised, or \code{-1} if
960+
an exception is raised. (It is not possible to determine whether a
961+
warning message is actually printed, nor what the reason is for the
962+
exception; this is intentional.) If an exception is raised, the
963+
caller should do its normal exception handling (e.g. DECREF owned
964+
references and return an error value).
965+
966+
Warning categories must be subclasses of \cdata{Warning}; the default
967+
warning category is \cdata{RuntimeWarning}. The standard Python
968+
warning categories are available as global variables whose names are
969+
\samp{PyExc_} followed by the Python exception name. These have the
970+
type \ctype{PyObject*}; they are all class objects. Their names are
971+
\cdata{PyExc_Warning}, \cdata{PyExc_UserWarning},
972+
\cdata{PyExc_DeprecationWarning}, \cdata{PyExc_SyntaxWarning}, and
973+
\cdata{PyExc_RuntimeWarning}. \cdata{PyExc_Warning} is a subclass of
974+
\cdata{PyExc_Exception}; the other warning categories are subclasses
975+
of \cdata{PyExc_Warning}.
976+
977+
For information about warning control, see the documentation for the
978+
\module{warnings} module and the \samp{-W} option in the command line
979+
documentation. There is no C API for warning control.
980+
\end{cfuncdesc}
981+
948982
\begin{cfuncdesc}{int}{PyErr_CheckSignals}{}
949983
This function interacts with Python's signal handling. It checks
950984
whether a signal has been sent to the processes and if so, invokes the

0 commit comments

Comments
 (0)