Repository navigation
Closed
Labels
interpreter-core(Objects, Python, Grammar, and Parser dirs)type-featureA feature request or enhancement
Description
| BPO | 7033 |
|---|---|
| Nosy | @birkenfeld, @pitrou, @bitdancer, @lekma |
| Files |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee = None
closed_at = <Date 2009-12-28.08:36:09.925>
created_at = <Date 2009-10-02.11:14:29.034>
labels = ['interpreter-core', 'type-feature']
title = 'C/API - Document exceptions'
updated_at = <Date 2009-12-30.07:26:45.211>
user = 'https://github.com/lekma'bugs.python.org fields:
activity = <Date 2009-12-30.07:26:45.211>
actor = 'lekma'
assignee = 'none'
closed = True
closed_date = <Date 2009-12-28.08:36:09.925>
closer = 'georg.brandl'
components = ['Interpreter Core']
creation = <Date 2009-10-02.11:14:29.034>
creator = 'lekma'
dependencies = []
files = ['15021', '15022', '15035', '15036', '15645', '15646']
hgrepos = []
issue_num = 7033
keywords = ['patch']
message_count = 19.0
messages = ['93439', '93448', '93449', '93484', '93526', '93527', '96667', '96675', '96676', '96677', '96679', '96680', '96682', '96740', '96741', '96943', '96946', '97009', '97022']
nosy_count = 4.0
nosy_names = ['georg.brandl', 'pitrou', 'r.david.murray', 'lekma']
pr_nums = []
priority = 'normal'
resolution = 'accepted'
stage = 'patch review'
status = 'closed'
superseder = None
type = 'enhancement'
url = 'https://bugs.python.org/issue7033'
versions = ['Python 2.7', 'Python 3.2']Metadata
Metadata
Assignees
Labels
interpreter-core(Objects, Python, Grammar, and Parser dirs)type-featureA feature request or enhancement
Activity
lekma commentedon Oct 2, 2009
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
exception.
if base is NULL, it creates a class object derived from Exception
(accessible in C as PyExc_Exception).
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.
lekma commentedon Oct 2, 2009
First attempt at implementing this.
Diff is against trunk.
lekma commentedon Oct 2, 2009
The same against py3k
birkenfeld commentedon Oct 3, 2009
Sounds like a useful new API. Two comments:
for *base* is easy enough.
"PyErr_NewException". Something like "PyErr_NewExceptionWithDoc" is better.
lekma commentedon Oct 4, 2009
Even though I don't fully agree with your comments here is a second
attempt addressing them, against trunk.
For the record, I think that the signature difference is enough to
warrant a name that is a clear cut from PyErr_NewException.
And in the spirit of the Py_InitModule and PyModule_Create families of
function I thought the most common/simple form should stand out from the
more complete one.
But, hey, I'm happy if this gets in (in any form :).
lekma commentedon Oct 4, 2009
Same as previous against py3k
lekma commentedon Dec 20, 2009
Is there any chance that this will make it in?
bitdancer commentedon Dec 20, 2009
Since it's a new CAPI I think it should probably be discussed briefly on
python-dev.
pitrou commentedon Dec 20, 2009
So do I.
bitdancer commentedon Dec 20, 2009
Also, what about tests?
birkenfeld commentedon Dec 20, 2009
Funnily, I already did ask on python-dev, and only got one (+1) answer
from Brett. I was going to add it some time when I have more cycles for
Python.
bitdancer commentedon Dec 20, 2009
Yes, I'd say that counts as a brief discussion :)
pitrou commentedon Dec 20, 2009
One nitpick: Python/errors.c uses tabs for indentation, your patch
should as well.
lekma commentedon Dec 21, 2009
patch against trunk:
lekma commentedon Dec 21, 2009
The same with a simpler test.
I leave it up to you guys to choose which one is the best.
birkenfeld commentedon Dec 28, 2009
Thanks for the patch! I rewrote the C function a bit to also take a dict
argument, and added a test for that. Committed in r77088. Will merge
to py3k.
lekma commentedon Dec 28, 2009
Great!
Thanks to all for the help!
birkenfeld commentedon Dec 29, 2009
lekma, this patch is now listed in the 2.7 "what's new" document as
contributed by "the lekma user", please tell us if you want your name there.
lekma commentedon Dec 30, 2009
Nope, that's ok (it's perfect).