@@ -1725,23 +1725,24 @@ class generic_type : public object {
17251725 // the internals capsule may be destroyed (resetting internals via internals_shutdown)
17261726 // before all pybind11 types are destroyed. If a type's tp_traverse/tp_clear then calls
17271727 // py::cast, it would recreate an empty internals and fail because the type registry is
1728- // gone. By holding references to the capsules, we ensure they outlive all pybind11
1729- // types. We use weakrefs on the type with a cpp_function callback. When the type is
1730- // destroyed, Python will call the callback which releases the capsule reference and
1731- // the weakref.
1728+ // gone.
1729+ //
1730+ // By holding references to the capsules, we ensure they outlive all pybind11 types. We
1731+ // use weakrefs on the type with a cpp_function callback. When the type is destroyed,
1732+ // Python will call the callback which releases the capsule reference and the weakref.
17321733 if (PyObject *capsule = get_internals_capsule ()) {
17331734 Py_INCREF (capsule);
1734- (void ) weakref (handle (m_ptr), cpp_function ([](handle prevent_release ) -> void {
1735+ (void ) weakref (handle (m_ptr), cpp_function ([](handle wr ) -> void {
17351736 Py_XDECREF (get_internals_capsule ());
1736- prevent_release .dec_ref ();
1737+ wr .dec_ref ();
17371738 }))
17381739 .release ();
17391740 }
17401741 if (PyObject *capsule = get_local_internals_capsule ()) {
17411742 Py_INCREF (capsule);
1742- (void ) weakref (handle (m_ptr), cpp_function ([](handle prevent_release ) -> void {
1743+ (void ) weakref (handle (m_ptr), cpp_function ([](handle wr ) -> void {
17431744 Py_XDECREF (get_local_internals_capsule ());
1744- prevent_release .dec_ref ();
1745+ wr .dec_ref ();
17451746 }))
17461747 .release ();
17471748 }
0 commit comments