-
-
Notifications
You must be signed in to change notification settings - Fork 31.1k
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
[C API] PyType_GetSlot() should accept static types #85245
Comments
To fix bpo-40170, I would like to modify Py_TRASHCAN_BEGIN() macro to use PyType_GetSlot() to get the deallocator function, rather than accessing directly the PyTypeObject.tp_dealloc member. The problem is that currently PyType_GetSlot() only works on heap allocated types. Would it be possible to add support for statically allocated types to PyType_GetSlot()? Py_TRASHCAN_BEGIN() is currently defined as: #define Py_TRASHCAN_BEGIN(op, dealloc) \
Py_TRASHCAN_BEGIN_CONDITION(op, \
Py_TYPE(op)->tp_dealloc == (destructor)(dealloc)) |
Hi, victor. If you have much bpo need to manage, I could take a look in this week :) |
historical discuss: bpo-17162 |
I create a PR in: https://github.com/shihai1991/cpython/pull/13/commits. If we extend PyType_GetSlot() to accept non-heaptype, we need find a way to judge the max slot of non-heaptype. |
bpo-17162 added PyType_GetSlot(), but static types were not discussed there. |
|
Static types can have some sub-slots structs but not others. A "max slot" will not help for types that have tp_as_mapping but not tp_as_number, for example. |
Looks like it's a good way to solve this probleam, Let me try it ;) |
Nice! It will be simpler to use PyType_GetSlot() in an extension with the limited C API, without having to care if the type is a static type or a heap type. |
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: