summaryrefslogtreecommitdiffstats
path: root/Include
diff options
context:
space:
mode:
authorBrett Cannon <bcannon@gmail.com>2008-04-12 23:44:07 (GMT)
committerBrett Cannon <bcannon@gmail.com>2008-04-12 23:44:07 (GMT)
commite9746890388178bb1e4cdad3c0586bf1862c3727 (patch)
tree77e228e19ac5673aac13dac8292281fc9a3010ab /Include
parente6c03033afc58804cfdb143bef67e9cd37e25507 (diff)
downloadcpython-e9746890388178bb1e4cdad3c0586bf1862c3727.zip
cpython-e9746890388178bb1e4cdad3c0586bf1862c3727.tar.gz
cpython-e9746890388178bb1e4cdad3c0586bf1862c3727.tar.bz2
Re-implement the 'warnings' module in C. This allows for usage of the
'warnings' code in places where it was previously not possible (e.g., the parser). It could also potentially lead to a speed-up in interpreter start-up if the C version of the code (_warnings) is imported over the use of the Python version in key places. Closes issue #1631171.
Diffstat (limited to 'Include')
-rw-r--r--Include/Python.h1
-rw-r--r--Include/pyerrors.h10
-rw-r--r--Include/sysmodule.h1
-rw-r--r--Include/traceback.h1
-rw-r--r--Include/warnings.h19
5 files changed, 22 insertions, 10 deletions
diff --git a/Include/Python.h b/Include/Python.h
index 4cffda3..2ff4c31 100644
--- a/Include/Python.h
+++ b/Include/Python.h
@@ -110,6 +110,7 @@
#include "iterobject.h"
#include "genobject.h"
#include "descrobject.h"
+#include "warnings.h"
#include "weakrefobject.h"
#include "codecs.h"
diff --git a/Include/pyerrors.h b/Include/pyerrors.h
index b687733..a4233c9 100644
--- a/Include/pyerrors.h
+++ b/Include/pyerrors.h
@@ -227,16 +227,6 @@ PyAPI_FUNC(PyObject *) PyErr_NewException(char *name, PyObject *base,
PyObject *dict);
PyAPI_FUNC(void) PyErr_WriteUnraisable(PyObject *);
-/* Issue a warning or exception */
-PyAPI_FUNC(int) PyErr_WarnEx(PyObject *category, const char *msg,
- Py_ssize_t stack_level);
-PyAPI_FUNC(int) PyErr_WarnExplicit(PyObject *, const char *,
- const char *, int,
- const char *, PyObject *);
-/* PyErr_Warn is only for backwards compatability and will be removed.
- Use PyErr_WarnEx instead. */
-#define PyErr_Warn(category, msg) PyErr_WarnEx(category, msg, 1)
-
/* In sigcheck.c or signalmodule.c */
PyAPI_FUNC(int) PyErr_CheckSignals(void);
PyAPI_FUNC(void) PyErr_SetInterrupt(void);
diff --git a/Include/sysmodule.h b/Include/sysmodule.h
index 1c9b187..536a180 100644
--- a/Include/sysmodule.h
+++ b/Include/sysmodule.h
@@ -23,6 +23,7 @@ PyAPI_DATA(int) _PySys_CheckInterval;
PyAPI_FUNC(void) PySys_ResetWarnOptions(void);
PyAPI_FUNC(void) PySys_AddWarnOption(char *);
+PyAPI_FUNC(int) PySys_HasWarnOptions(void);
#ifdef __cplusplus
}
diff --git a/Include/traceback.h b/Include/traceback.h
index 0b3bfae..b77cc92 100644
--- a/Include/traceback.h
+++ b/Include/traceback.h
@@ -19,6 +19,7 @@ typedef struct _traceback {
PyAPI_FUNC(int) PyTraceBack_Here(struct _frame *);
PyAPI_FUNC(int) PyTraceBack_Print(PyObject *, PyObject *);
+PyAPI_FUNC(int) Py_DisplaySourceLine(PyObject *, const char *, int);
/* Reveal traceback type so we can typecheck traceback objects */
PyAPI_DATA(PyTypeObject) PyTraceBack_Type;
diff --git a/Include/warnings.h b/Include/warnings.h
new file mode 100644
index 0000000..e93b72c
--- /dev/null
+++ b/Include/warnings.h
@@ -0,0 +1,19 @@
+#ifndef Py_WARNINGS_H
+#define Py_WARNINGS_H
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+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 *);
+
+/* DEPRECATED: Use PyErr_WarnEx() instead. */
+#define PyErr_Warn(category, msg) PyErr_WarnEx(category, msg, 1)
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* !Py_WARNINGS_H */ \ No newline at end of file