]> granicus.if.org Git - python/commitdiff
Added PyErr_WarnPy3k function. (issue 2671) I will be converting current Py3k warning...
authorBenjamin Peterson <benjamin@python.org>
Sun, 27 Apr 2008 02:28:02 +0000 (02:28 +0000)
committerBenjamin Peterson <benjamin@python.org>
Sun, 27 Apr 2008 02:28:02 +0000 (02:28 +0000)
Doc/c-api/exceptions.rst
Include/warnings.h
Misc/NEWS
Python/_warnings.c

index 133bac94bc9642977f0c388e4ba9c68addb2144b..29985218e4087c3633b44f86da3bdc734f5b32d1 100644 (file)
@@ -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::
index 5d1343121496007e3fb3c5e18acaf1e17808674f..e761adeb85a654b1a032b6dc2311eae511c2e452 100644 (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_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)
index 9bd4f59ec80cd1deee760e54195057a69189f115..7effe656f5ed11740c6099c1d0e9fb9dac2fd95e 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -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?
 =================================
index bb688b1be0347a73e52225bf9e88eadd235c4b55..88afade15ba753fbeb8c5be23abe33f490dd0b78 100644 (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,
 "Issue a warning, or maybe ignore it or raise an exception.");