From: Georg Brandl Date: Mon, 6 Oct 2014 10:58:36 +0000 (+0200) Subject: merge with 3.4 X-Git-Tag: v3.5.0a1~746 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b65ff1d4f312c1e5c5ebee73470171731d3bbfff;p=python merge with 3.4 --- b65ff1d4f312c1e5c5ebee73470171731d3bbfff diff --cc Doc/c-api/exceptions.rst index d0d4906a58,8ad742afef..8e70560776 --- a/Doc/c-api/exceptions.rst +++ b/Doc/c-api/exceptions.rst @@@ -266,23 -346,7 +266,23 @@@ NULL pointer for use in a ``return`` st use. +Issuing warnings +================ + +Use these functions to issue warnings from C code. They mirror similar +functions exported by the Python :mod:`warnings` module. They normally +print a warning message to *sys.stderr*; however, it is +also possible that the user has specified that warnings are to be turned into +errors, and in that case they will raise an exception. It is also possible that +the functions raise an exception because of a problem with the warning machinery. +The return value is ``0`` if no exception is raised, or ``-1`` if an exception +is raised. (It is not possible to determine whether a warning message is +actually printed, nor what the reason is for the exception; this is +intentional.) If an exception is raised, the caller should do its normal +exception handling (for example, :c:func:`Py_DECREF` owned references and return +an error value). + - .. c:function:: int PyErr_WarnEx(PyObject *category, char *message, int stack_level) + .. c:function:: int PyErr_WarnEx(PyObject *category, const char *message, Py_ssize_t stack_level) Issue a warning message. The *category* argument is a warning category (see below) or *NULL*; the *message* argument is an UTF-8 encoded string. *stack_level* is a