File tree 2 files changed +32
-1
lines changed 2 files changed +32
-1
lines changed Original file line number Diff line number Diff line change 1
- // Copyright (c) 2025 The Pybind Development Team .
1
+ // Copyright (c) 2025 The pybind Community .
2
2
// All rights reserved. Use of this source code is governed by a
3
3
// BSD-style license that can be found in the LICENSE file.
4
4
Original file line number Diff line number Diff line change
1
+ # Copyright (c) 2025 The pybind Community.
2
+ # All rights reserved. Use of this source code is governed by a
3
+ # BSD-style license that can be found in the LICENSE file.
4
+
5
+ # This module tests the interaction of pybind11's shared_ptr and smart_holder
6
+ # mechanisms with trampoline object lifetime management and inheritance slicing.
7
+ #
8
+ # The following combinations are covered:
9
+ #
10
+ # - Holder type: std::shared_ptr (class_ holder) vs.
11
+ # py::smart_holder
12
+ # - Conversion function: obj.cast<std::shared_ptr<T>>() vs.
13
+ # py::potentially_slicing_shared_ptr<T>(obj)
14
+ # - Python object type: C++ base class vs.
15
+ # Python-derived trampoline class
16
+ #
17
+ # The tests verify
18
+ #
19
+ # - that casting or passing Python objects into functions returns usable
20
+ # std::shared_ptr<T> instances.
21
+ # - that inheritance slicing occurs as expected in controlled cases
22
+ # (issue #1333).
23
+ # - that surprising weak_ptr behavior (issue #5623) can be reproduced when
24
+ # smart_holder is used.
25
+ # - that the trampoline object remains alive in all situations
26
+ # (no use-after-free) as long as the C++ shared_ptr exists.
27
+ #
28
+ # Where applicable, trampoline state is introspected to confirm whether the
29
+ # C++ object retains knowledge of the Python override or has fallen back to
30
+ # the base implementation.
31
+
1
32
from __future__ import annotations
2
33
3
34
import gc
You can’t perform that action at this time.
0 commit comments