Skip to content

Commit 7c5d505

Browse files
committed
Move code location
1 parent d9227ce commit 7c5d505

1 file changed

Lines changed: 9 additions & 8 deletions

File tree

include/pybind11/pybind11.h

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)