Skip to content

Commit a692c4d

Browse files
committed
Added PyErr_WarnPy3k function. (issue 2671) I will be converting current Py3k warnings to the use of this function soon.
1 parent ba08f07 commit a692c4d

4 files changed

Lines changed: 21 additions & 0 deletions

File tree

Doc/c-api/exceptions.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,14 @@ is a separate error indicator for each thread.
344344
described there.
345345

346346

347+
.. cfunction:: int PyErr_WarnPy3k(char *message, int stacklevel)
348+
349+
Issue a :exc:`DeprecationWarning` with the given *message* and *stacklevel*
350+
if the :cdata:`Py_Py3kWarningFlag` flag is enabled.
351+
352+
.. versionadded:: 2.6
353+
354+
347355
.. cfunction:: int PyErr_CheckSignals()
348356

349357
.. index::

Include/warnings.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ PyAPI_FUNC(void) _PyWarnings_Init(void);
99
PyAPI_FUNC(int) PyErr_WarnEx(PyObject *, const char *, Py_ssize_t);
1010
PyAPI_FUNC(int) PyErr_WarnExplicit(PyObject *, const char *, const char *, int,
1111
const char *, PyObject *);
12+
PyAPI_FUNC(int) PyErr_WarnPy3k(const char *, Py_ssize_t);
1213

1314
/* DEPRECATED: Use PyErr_WarnEx() instead. */
1415
#define PyErr_Warn(category, msg) PyErr_WarnEx(category, msg, 1)

Misc/NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,9 @@ C API
143143
platforms which provide the functions through their libm. The
144144
files also contains several helpers and constants for math.
145145

146+
- Added a new convenience function, PyErr_WarnPy3k, for issuing Py3k
147+
warnings.
148+
146149

147150
What's New in Python 2.6 alpha 2?
148151
=================================

Python/_warnings.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -732,6 +732,15 @@ PyErr_WarnExplicit(PyObject *category, const char *text,
732732
}
733733

734734

735+
int
736+
PyErr_WarnPy3k(const char *text, Py_ssize_t stacklevel)
737+
{
738+
if (Py_Py3kWarningFlag)
739+
return PyErr_WarnEx(PyExc_DeprecationWarning, text, stacklevel);
740+
return 0;
741+
}
742+
743+
735744
PyDoc_STRVAR(warn_doc,
736745
"Issue a warning, or maybe ignore it or raise an exception.");
737746

0 commit comments

Comments
 (0)