diff options
author | Georg Brandl <georg@python.org> | 2009-12-28 08:41:01 (GMT) |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2009-12-28 08:41:01 (GMT) |
commit | 1e28a27f845a59513ad3bebbd6ae19f399071bbd (patch) | |
tree | 22f39f9b43f61a56fbcca9327b968685159e7f00 /Modules | |
parent | 127d47092a98aa9b668dceb03c7b64d9c4c44adc (diff) | |
download | cpython-1e28a27f845a59513ad3bebbd6ae19f399071bbd.zip cpython-1e28a27f845a59513ad3bebbd6ae19f399071bbd.tar.gz cpython-1e28a27f845a59513ad3bebbd6ae19f399071bbd.tar.bz2 |
Merged revisions 77088 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r77088 | georg.brandl | 2009-12-28 09:34:58 +0100 (Mo, 28 Dez 2009) | 1 line
#7033: add new API function PyErr_NewExceptionWithDoc, for easily giving new exceptions a docstring.
........
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/_testcapimodule.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/Modules/_testcapimodule.c b/Modules/_testcapimodule.c index e549151..19afbf2 100644 --- a/Modules/_testcapimodule.c +++ b/Modules/_testcapimodule.c @@ -1716,6 +1716,26 @@ code_newempty(PyObject *self, PyObject *args) return (PyObject *)PyCode_NewEmpty(filename, funcname, firstlineno); } +/* Test PyErr_NewExceptionWithDoc (also exercise PyErr_NewException). + Run via Lib/test/test_exceptions.py */ +static PyObject * +make_exception_with_doc(PyObject *self, PyObject *args, PyObject *kwargs) +{ + const char *name; + const char *doc = NULL; + PyObject *base = NULL; + PyObject *dict = NULL; + + static char *kwlist[] = {"name", "doc", "base", "dict", NULL}; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "s|sOO:make_exception_with_doc", kwlist, + &name, &doc, &base, &dict)) + return NULL; + + return PyErr_NewExceptionWithDoc(name, doc, base, dict); +} + static PyMethodDef TestMethods[] = { {"raise_exception", raise_exception, METH_VARARGS}, {"raise_memoryerror", (PyCFunction)raise_memoryerror, METH_NOARGS}, @@ -1774,6 +1794,8 @@ static PyMethodDef TestMethods[] = { {"exception_print", exception_print, METH_VARARGS}, {"argparsing", argparsing, METH_VARARGS}, {"code_newempty", code_newempty, METH_VARARGS}, + {"make_exception_with_doc", (PyCFunction)make_exception_with_doc, + METH_VARARGS | METH_KEYWORDS}, {NULL, NULL} /* sentinel */ }; |