Added PyErr_WarnPy3k function. (issue 2671) I will be converting current Py3k warnings to the use of this function soon.

This commit is contained in:
Benjamin Peterson 2008-04-27 02:28:02 +00:00
parent ba08f072d2
commit a692c4df63
4 changed files with 21 additions and 0 deletions

View file

@ -344,6 +344,14 @@ is a separate error indicator for each thread.
described there. described there.
.. cfunction:: int PyErr_WarnPy3k(char *message, int stacklevel)
Issue a :exc:`DeprecationWarning` with the given *message* and *stacklevel*
if the :cdata:`Py_Py3kWarningFlag` flag is enabled.
.. versionadded:: 2.6
.. cfunction:: int PyErr_CheckSignals() .. cfunction:: int PyErr_CheckSignals()
.. index:: .. index::

View file

@ -9,6 +9,7 @@ PyAPI_FUNC(void) _PyWarnings_Init(void);
PyAPI_FUNC(int) PyErr_WarnEx(PyObject *, const char *, Py_ssize_t); PyAPI_FUNC(int) PyErr_WarnEx(PyObject *, const char *, Py_ssize_t);
PyAPI_FUNC(int) PyErr_WarnExplicit(PyObject *, const char *, const char *, int, PyAPI_FUNC(int) PyErr_WarnExplicit(PyObject *, const char *, const char *, int,
const char *, PyObject *); const char *, PyObject *);
PyAPI_FUNC(int) PyErr_WarnPy3k(const char *, Py_ssize_t);
/* DEPRECATED: Use PyErr_WarnEx() instead. */ /* DEPRECATED: Use PyErr_WarnEx() instead. */
#define PyErr_Warn(category, msg) PyErr_WarnEx(category, msg, 1) #define PyErr_Warn(category, msg) PyErr_WarnEx(category, msg, 1)

View file

@ -143,6 +143,9 @@ C API
platforms which provide the functions through their libm. The platforms which provide the functions through their libm. The
files also contains several helpers and constants for math. files also contains several helpers and constants for math.
- Added a new convenience function, PyErr_WarnPy3k, for issuing Py3k
warnings.
What's New in Python 2.6 alpha 2? What's New in Python 2.6 alpha 2?
================================= =================================

View file

@ -732,6 +732,15 @@ PyErr_WarnExplicit(PyObject *category, const char *text,
} }
int
PyErr_WarnPy3k(const char *text, Py_ssize_t stacklevel)
{
if (Py_Py3kWarningFlag)
return PyErr_WarnEx(PyExc_DeprecationWarning, text, stacklevel);
return 0;
}
PyDoc_STRVAR(warn_doc, PyDoc_STRVAR(warn_doc,
"Issue a warning, or maybe ignore it or raise an exception."); "Issue a warning, or maybe ignore it or raise an exception.");