@@ -611,20 +611,20 @@ Payload *atomic_get_or_create_in_state_dict(const char *key) {
611611 throw error_already_set ();
612612 }
613613 }
614+ // - If key already existed, our `new_capsule` is not inserted, it will be destructed
615+ // when going out of scope here, which will also free the storage.
616+ // - Otherwise, our `new_capsule` is now in the dict, and it owns the storage and the
617+ // state dict will incref it.
614618 }
615- // - If key already existed, our `new_capsule` is not inserted, it will be destructed
616- // when going out of scope here, which will also free the storage.
617- // - Otherwise, our `new_capsule` is now in the dict, and it owns the storage and the
618- // state dict will incref it.
619- }
620619
621- // Get the storage pointer from the capsule.
622- void *raw_ptr = PyCapsule_GetPointer(capsule_obj, /* name=*/ nullptr );
623- if (!raw_ptr) {
624- raise_from (PyExc_SystemError, " pybind11::detail::atomic_get_or_create_in_state_dict() FAILED" );
625- throw error_already_set ();
626- }
627- return static_cast <Payload *>(raw_ptr);
620+ // Get the storage pointer from the capsule.
621+ void *raw_ptr = PyCapsule_GetPointer (capsule_obj, /* name=*/ nullptr );
622+ if (!raw_ptr) {
623+ raise_from (PyExc_SystemError,
624+ " pybind11::detail::atomic_get_or_create_in_state_dict() FAILED" );
625+ throw error_already_set ();
626+ }
627+ return static_cast <Payload *>(raw_ptr);
628628}
629629
630630template <typename InternalsType>
0 commit comments