Skip to content

Commit f35fdc0

Browse files
committed
incorporated feedback by @dean0x7d
1 parent c4af5bd commit f35fdc0

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

include/pybind11/pytypes.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1011,7 +1011,14 @@ class capsule : public object {
10111011
pybind11_fail("Could not allocate capsule object!");
10121012
}
10131013

1014-
explicit capsule(const void *value, void (*destructor)(void *)) {
1014+
PYBIND11_DEPRECATED("Please pass a destructor that takes a void pointer as input")
1015+
capsule(const void *value, void (*destruct)(PyObject *))
1016+
: object(PyCapsule_New(const_cast<void*>(value), nullptr, destruct), stolen) {
1017+
if (!m_ptr)
1018+
pybind11_fail("Could not allocate capsule object!");
1019+
}
1020+
1021+
capsule(const void *value, void (*destructor)(void *)) {
10151022
m_ptr = PyCapsule_New(const_cast<void *>(value), nullptr, [](PyObject *o) {
10161023
auto destructor = reinterpret_cast<void (*)(void *)>(PyCapsule_GetContext(o));
10171024
void *ptr = PyCapsule_GetPointer(o, nullptr);

0 commit comments

Comments
 (0)