-
-
Notifications
You must be signed in to change notification settings - Fork 30.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create alternative CObject API that is safe and clean #49880
Comments
The CObject API has two flaws. First, there is no usable type safety mechanism. You can store a void Second, the destructor callback is defined as taking *either* one *or* MvL and I discussed this last night and decided to float a revision of The color of this particular bike shed is:
Yes, you can easily skip around the "matching type" restriction by The attached patch was written py3k/trunk r70718. It compiles with no Note: this patch is not complete; I fixed all the .c and .h files, but I |
Two questions:
A comment: Suppose one wants to implement export/import module C-API's in a As the void* <-> void(*)(void) conversion is illegal(?) in C(99?), one Do you have any idea on how extend the CObject API for the commented use |
dalcinl: I made the destructor the first argument because APIs where arguments We don't really need two different calls for providing a context As for your "comment", I see CObject as a lightweight way of making a |
Sorry, in editing I forgot to finish my sentence. In the middle of the But 90% of the time all you'll need is PyCObject_FromVoidPtr(). My other editing mistakes will just have to stand. |
Having slept on it, I agree that we only need one API to create an |
I discussed this off-list with GvR. He was primarily concerned with The new object is called a "Capsule". (I *had* wanted to call it
I've attached a patch to implement this; it was written against svn GvR and I disagree on one point: he thinks that we should leave CObject |
I've updated the patch:
This is as far as I can take the patch without some input from the |
Whoopsie-daisy, I forgot to touch up a whole lot of places to match the
|
Added a test case for capsules to _testcapimodule.c, and updated to the |
Updated patch based on impressively thorough Rietveld feedback from This patch should not be considered final; we already know the API |
In Doc/c-api/capsule.rst, you wrote .. cfunction:: int PyCapsule_Import(const char* name, int no_block) but it should be: .. cfunction:: void* PyCapsule_Import(const char* name, int no_block) Additionally, you wrote "disambugate" in many places. |
dalcinl: Thanks, I've fixed the doc wrt writing "int" where I meant As for using "disambiguate" in many places: there are a couple of |
A nice fresh patch, against r72309. Incorporates changes based on Note: this still has CObject flagged as deprecated, both in doc and with |
Applied in r72363. |
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:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: