This issue tracker has been migrated to GitHub ,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2009年10月02日 11:14 by lekma, last changed 2022年04月11日 14:56 by admin. This issue is now closed.
Files | ||||
---|---|---|---|---|
File name | Uploaded | Description | Edit | |
issue7033_trunk.diff | lekma, 2009年10月02日 17:23 | |||
issue7033_py3k.diff | lekma, 2009年10月02日 17:24 | |||
issue7033_trunk_2.diff | lekma, 2009年10月04日 09:34 | |||
issue7033_py3k_2.diff | lekma, 2009年10月04日 09:36 | |||
issue7033_trunk_3.diff | lekma, 2009年12月21日 11:50 | |||
issue7033_trunk_3_alt_test.diff | lekma, 2009年12月21日 11:52 |
Messages (19) | |||
---|---|---|---|
msg93439 - (view) | Author: (lekma) * | Date: 2009年10月02日 11:14 | |
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). 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. |
|||
msg93448 - (view) | Author: (lekma) * | Date: 2009年10月02日 17:23 | |
First attempt at implementing this. Diff is against trunk. |
|||
msg93449 - (view) | Author: (lekma) * | Date: 2009年10月02日 17:24 | |
The same against py3k |
|||
msg93484 - (view) | Author: Georg Brandl (georg.brandl) * (Python committer) | Date: 2009年10月03日 09:30 | |
Sounds like a useful new API. Two comments: * The version without *base* is not needed. Passing an explicit NULL for *base* is easy enough. * The name "PyErr_Create" is needlessly different from "PyErr_NewException". Something like "PyErr_NewExceptionWithDoc" is better. |
|||
msg93526 - (view) | Author: (lekma) * | Date: 2009年10月04日 09:34 | |
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 :). |
|||
msg93527 - (view) | Author: (lekma) * | Date: 2009年10月04日 09:36 | |
Same as previous against py3k |
|||
msg96667 - (view) | Author: (lekma) * | Date: 2009年12月20日 09:21 | |
Is there any chance that this will make it in? |
|||
msg96675 - (view) | Author: R. David Murray (r.david.murray) * (Python committer) | Date: 2009年12月20日 14:06 | |
Since it's a new CAPI I think it should probably be discussed briefly on python-dev. |
|||
msg96676 - (view) | Author: Antoine Pitrou (pitrou) * (Python committer) | Date: 2009年12月20日 14:08 | |
> Since it's a new CAPI I think it should probably be discussed briefly on > python-dev. So do I. |
|||
msg96677 - (view) | Author: R. David Murray (r.david.murray) * (Python committer) | Date: 2009年12月20日 14:09 | |
Also, what about tests? |
|||
msg96679 - (view) | Author: Georg Brandl (georg.brandl) * (Python committer) | Date: 2009年12月20日 14:13 | |
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. |
|||
msg96680 - (view) | Author: R. David Murray (r.david.murray) * (Python committer) | Date: 2009年12月20日 14:14 | |
Yes, I'd say that counts as a brief discussion :) |
|||
msg96682 - (view) | Author: Antoine Pitrou (pitrou) * (Python committer) | Date: 2009年12月20日 14:23 | |
One nitpick: Python/errors.c uses tabs for indentation, your patch should as well. |
|||
msg96740 - (view) | Author: (lekma) * | Date: 2009年12月21日 11:50 | |
patch against trunk: - fix tabs issue (I hope) - add test |
|||
msg96741 - (view) | Author: (lekma) * | Date: 2009年12月21日 11:52 | |
The same with a simpler test. I leave it up to you guys to choose which one is the best. |
|||
msg96943 - (view) | Author: Georg Brandl (georg.brandl) * (Python committer) | Date: 2009年12月28日 08:36 | |
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. |
|||
msg96946 - (view) | Author: (lekma) * | Date: 2009年12月28日 14:08 | |
> 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. Great! Thanks to all for the help! |
|||
msg97009 - (view) | Author: Georg Brandl (georg.brandl) * (Python committer) | Date: 2009年12月29日 21:41 | |
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. |
|||
msg97022 - (view) | Author: (lekma) * | Date: 2009年12月30日 07:26 | |
> 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. Nope, that's ok (it's perfect). |
History | |||
---|---|---|---|
Date | User | Action | Args |
2022年04月11日 14:56:53 | admin | set | github: 51282 |
2009年12月30日 07:26:45 | lekma | set | messages: + msg97022 |
2009年12月29日 21:41:26 | georg.brandl | set | messages: + msg97009 |
2009年12月28日 14:08:01 | lekma | set | messages: + msg96946 |
2009年12月28日 08:36:09 | georg.brandl | set | status: open -> closed resolution: accepted messages: + msg96943 |
2009年12月21日 11:52:08 | lekma | set | files:
+ issue7033_trunk_3_alt_test.diff messages: + msg96741 |
2009年12月21日 11:50:21 | lekma | set | files:
+ issue7033_trunk_3.diff messages: + msg96740 |
2009年12月20日 14:23:21 | pitrou | set | messages: + msg96682 |
2009年12月20日 14:14:49 | r.david.murray | set | messages: + msg96680 |
2009年12月20日 14:13:36 | georg.brandl | set | messages: + msg96679 |
2009年12月20日 14:09:10 | r.david.murray | set | messages: + msg96677 |
2009年12月20日 14:08:06 | pitrou | set | nosy:
+ pitrou messages: + msg96676 |
2009年12月20日 14:06:15 | r.david.murray | set | priority: normal nosy: + r.david.murray messages: + msg96675 stage: patch review |
2009年12月20日 09:21:52 | lekma | set | messages: + msg96667 |
2009年10月04日 09:36:11 | lekma | set | files:
+ issue7033_py3k_2.diff messages: + msg93527 |
2009年10月04日 09:34:54 | lekma | set | files:
+ issue7033_trunk_2.diff messages: + msg93526 |
2009年10月03日 09:30:07 | georg.brandl | set | nosy:
+ georg.brandl messages: + msg93484 |
2009年10月02日 17:24:26 | lekma | set | files:
+ issue7033_py3k.diff messages: + msg93449 |
2009年10月02日 17:23:31 | lekma | set | files:
+ issue7033_trunk.diff keywords: + patch messages: + msg93448 |
2009年10月02日 11:14:29 | lekma | create |