File tree 1 file changed +6
-6
lines changed 1 file changed +6
-6
lines changed Original file line number Diff line number Diff line change @@ -1829,18 +1829,18 @@ class capsule : public object {
1829
1829
// guard if destructor called while err indicator is set
1830
1830
error_scope error_guard;
1831
1831
auto destructor = reinterpret_cast <void (*)(void *)>(PyCapsule_GetContext (o));
1832
- if (destructor == nullptr ) {
1833
- if (PyErr_Occurred ()) {
1834
- throw error_already_set ();
1835
- }
1836
- pybind11_fail (" Unable to get capsule context" );
1832
+ if (PyErr_Occurred ()) {
1833
+ throw error_already_set ();
1837
1834
}
1838
1835
const char *name = get_name_in_error_scope (o);
1839
1836
void *ptr = PyCapsule_GetPointer (o, name);
1840
1837
if (ptr == nullptr ) {
1841
1838
throw error_already_set ();
1842
1839
}
1843
- destructor (ptr);
1840
+
1841
+ if (destructor != nullptr ) {
1842
+ destructor (ptr);
1843
+ }
1844
1844
});
1845
1845
1846
1846
if (!m_ptr || PyCapsule_SetContext (m_ptr, (void *) destructor) != 0 ) {
You can’t perform that action at this time.
0 commit comments