diff options
author | Benjamin Peterson <benjamin@python.org> | 2008-04-27 02:28:02 (GMT) |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2008-04-27 02:28:02 (GMT) |
commit | a692c4df63a41c42f2ce10a4521136d1440a712d (patch) | |
tree | b754f5f3a130f6e4f672585b1134601a25ee178d | |
parent | ba08f072d29f2108503a97bf495315e072ae7787 (diff) | |
download | cpython-a692c4df63a41c42f2ce10a4521136d1440a712d.zip cpython-a692c4df63a41c42f2ce10a4521136d1440a712d.tar.gz cpython-a692c4df63a41c42f2ce10a4521136d1440a712d.tar.bz2 |
Added PyErr_WarnPy3k function. (issue 2671) I will be converting current Py3k warnings to the use of this function soon.
-rw-r--r-- | Doc/c-api/exceptions.rst | 8 | ||||
-rw-r--r-- | Include/warnings.h | 1 | ||||
-rw-r--r-- | Misc/NEWS | 3 | ||||
-rw-r--r-- | Python/_warnings.c | 9 |
4 files changed, 21 insertions, 0 deletions
diff --git a/Doc/c-api/exceptions.rst b/Doc/c-api/exceptions.rst index 133bac9..2998521 100644 --- a/Doc/c-api/exceptions.rst +++ b/Doc/c-api/exceptions.rst @@ -344,6 +344,14 @@ is a separate error indicator for each thread. 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() .. index:: diff --git a/Include/warnings.h b/Include/warnings.h index 5d13431..e761ade 100644 --- a/Include/warnings.h +++ b/Include/warnings.h @@ -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_WarnExplicit(PyObject *, const char *, const char *, int, const char *, PyObject *); +PyAPI_FUNC(int) PyErr_WarnPy3k(const char *, Py_ssize_t); /* DEPRECATED: Use PyErr_WarnEx() instead. */ #define PyErr_Warn(category, msg) PyErr_WarnEx(category, msg, 1) @@ -143,6 +143,9 @@ C API platforms which provide the functions through their libm. The 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? ================================= diff --git a/Python/_warnings.c b/Python/_warnings.c index bb688b1..88afade 100644 --- a/Python/_warnings.c +++ b/Python/_warnings.c @@ -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, "Issue a warning, or maybe ignore it or raise an exception."); |