Skip to content

Commit 2e2b7fe

Browse files
committed
Appease warnings for MSVC
1 parent 0efd867 commit 2e2b7fe

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

include/pybind11/detail/internals.h

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)