File tree Expand file tree Collapse file tree 1 file changed +7
-5
lines changed
Expand file tree Collapse file tree 1 file changed +7
-5
lines changed Original file line number Diff line number Diff line change @@ -604,11 +604,13 @@ Payload *atomic_get_or_create_in_state_dict(const char *key) {
604604 if (capsule_obj == nullptr ) {
605605 throw error_already_set ();
606606 }
607- if (LeakOnInterpreterShutdown && capsule_obj == new_capsule.ptr ()) {
608- // Our capsule was inserted.
609- // Remove the destructor to leak the storage on interpreter shutdown.
610- if (PyCapsule_SetDestructor (capsule_obj, nullptr ) < 0 ) {
611- throw error_already_set ();
607+ if PYBIND11_MAYBE_CONSTEXPR (LeakOnInterpreterShutdown) {
608+ if (capsule_obj == new_capsule.ptr ()) {
609+ // Our capsule was inserted.
610+ // Remove the destructor to leak the storage on interpreter shutdown.
611+ if (PyCapsule_SetDestructor (capsule_obj, nullptr ) < 0 ) {
612+ throw error_already_set ();
613+ }
612614 }
613615 }
614616 // - If key already existed, our `new_capsule` is not inserted, it will be destructed
You can’t perform that action at this time.
0 commit comments