#7033: add new API function PyErr_NewExceptionWithDoc, for easily giving new exceptions a docstring.
diff --git a/Modules/_testcapimodule.c b/Modules/_testcapimodule.c
index c8f2087..f0dd75e 100644
--- a/Modules/_testcapimodule.c
+++ b/Modules/_testcapimodule.c
@@ -1198,6 +1198,26 @@
 	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)
+{
+	char *name;
+	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},
 	{"test_config",		(PyCFunction)test_config,	 METH_NOARGS},
@@ -1248,6 +1268,8 @@
 #endif
 	{"traceback_print", traceback_print, 	         METH_VARARGS},
 	{"code_newempty", code_newempty, 	         METH_VARARGS},
+	{"make_exception_with_doc", (PyCFunction)make_exception_with_doc,
+	 METH_VARARGS | METH_KEYWORDS},
 	{NULL, NULL} /* sentinel */
 };