We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent ff7b697 commit 0927c4dCopy full SHA for 0927c4d
include/pybind11/pytypes.h
@@ -1829,7 +1829,7 @@ class capsule : public object {
1829
// guard if destructor called while err indicator is set
1830
error_scope error_guard;
1831
auto destructor = reinterpret_cast<void (*)(void *)>(PyCapsule_GetContext(o));
1832
- if (PyErr_Occurred()) {
+ if (destructor == nullptr && PyErr_Occurred()) {
1833
throw error_already_set();
1834
}
1835
const char *name = get_name_in_error_scope(o);
@@ -1843,7 +1843,7 @@ class capsule : public object {
1843
1844
});
1845
1846
- if (!m_ptr || PyCapsule_SetContext(m_ptr, (void *) destructor) != 0) {
+ if (!m_ptr || PyCapsule_SetContext(m_ptr, reinterpret_cast<void *>(destructor)) != 0) {
1847
1848
1849
0 commit comments