Skip to content

Commit c5d2a68

Browse files
committed
add optional name and destructor
1 parent e45c211 commit c5d2a68

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

include/pybind11/pytypes.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1016,8 +1016,8 @@ class capsule : public object {
10161016
PYBIND11_DEPRECATED("Use reinterpret_borrow<capsule>() or reinterpret_steal<capsule>()")
10171017
capsule(PyObject *ptr, bool is_borrowed) : object(is_borrowed ? object(ptr, borrowed_t{}) : object(ptr, stolen_t{})) { }
10181018

1019-
explicit capsule(const void *value)
1020-
: object(PyCapsule_New(const_cast<void *>(value), nullptr, nullptr), stolen_t{}) {
1019+
explicit capsule(const void *value, const char *name = nullptr, void (*destructor)(PyObject *) = nullptr)
1020+
: object(PyCapsule_New(const_cast<void *>(value), name, destructor), stolen_t{}) {
10211021
if (!m_ptr)
10221022
pybind11_fail("Could not allocate capsule object!");
10231023
}

0 commit comments

Comments
 (0)