[New-bugs-announce] [issue7033] C/API - Document exceptions

lekma report at bugs.python.org
Fri Oct 2 13:14:30 CEST 2009

New submission from lekma <lekmalek at gmail.com>:

It would be nice to have an obvious/simple way to document C exceptions
(especially when using the autoexception feature from Sphinx).

Something along:

PyObject *PyErr_Create(char *name, const char *doc)
    Creates and returns a new exception object.
    This behaves like PyErr_Create2() with base set to NULL.

PyObject *PyErr_Create2(char *name, const char *doc, PyObject *base)
    Creates and returns a new exception object.
    The name argument must be the name of the new exception, a C string
of the form module.class.
    If doc is non-NULL, it will be used to define the docstring for the
    if base is NULL, it creates a class object derived from Exception
(accessible in C as PyExc_Exception).

for py3k the signatures would be:
PyObject *PyErr_Create(const char *name, const char *doc)
PyObject *PyErr_Create2(const char *name, const char *doc, PyObject *base)

Internally, these functions would pass a dict to PyErr_NewException with
the key '__doc__' set to doc.

If there is support for this, I can provide patches for trunk and py3k.

components: Interpreter Core
messages: 93439
nosy: lekma
severity: normal
status: open
title: C/API - Document exceptions
type: feature request
versions: Python 2.7, Python 3.2

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list