summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2000-12-15 22:02:05 (GMT)
committerGuido van Rossum <guido@python.org>2000-12-15 22:02:05 (GMT)
commit23fff911a2e0185d3f4618cd02a7b051b55fdd7e (patch)
tree11f84ff88f8fa4a41114490d94416e60562733c3 /Python
parent429b41e5ae0f4a20b55328f87daf1f2817f6a068 (diff)
downloadcpython-23fff911a2e0185d3f4618cd02a7b051b55fdd7e.zip
cpython-23fff911a2e0185d3f4618cd02a7b051b55fdd7e.tar.gz
cpython-23fff911a2e0185d3f4618cd02a7b051b55fdd7e.tar.bz2
Add definitions for PySys_ResetWarnOptions() and
PySys_AddWarnOption().
Diffstat (limited to 'Python')
-rw-r--r--Python/sysmodule.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/Python/sysmodule.c b/Python/sysmodule.c
index b569a9a..33d71ac 100644
--- a/Python/sysmodule.c
+++ b/Python/sysmodule.c
@@ -391,6 +391,34 @@ list_builtin_module_names(void)
return list;
}
+static PyObject *warnoptions = NULL;
+
+void
+PySys_ResetWarnOptions(void)
+{
+ if (warnoptions == NULL || !PyList_Check(warnoptions))
+ return;
+ PyList_SetSlice(warnoptions, 0, PyList_GET_SIZE(warnoptions), NULL);
+}
+
+void
+PySys_AddWarnOption(char *s)
+{
+ PyObject *str;
+
+ if (warnoptions == NULL || !PyList_Check(warnoptions)) {
+ Py_XDECREF(warnoptions);
+ warnoptions = PyList_New(0);
+ if (warnoptions == NULL)
+ return;
+ }
+ str = PyString_FromString(s);
+ if (str != NULL) {
+ PyList_Append(warnoptions, str);
+ Py_DECREF(str);
+ }
+}
+
/* XXX This doc string is too long to be a single string literal in VC++ 5.0.
Two literals concatenated works just fine. If you have a K&R compiler
or other abomination that however *does* understand longer strings,
@@ -553,6 +581,17 @@ _PySys_Init(void)
v = PyString_FromString(PyWin_DLLVersionString));
Py_XDECREF(v);
#endif
+ if (warnoptions == NULL) {
+ warnoptions = PyList_New(0);
+ }
+ else {
+ Py_INCREF(warnoptions);
+ }
+ if (warnoptions != NULL) {
+ PyDict_SetItemString(sysdict, "warnoptions", v = warnoptions);
+ Py_DECREF(v);
+ }
+
if (PyErr_Occurred())
return NULL;
return m;