Skip to content

Commit 78178d7

Browse files
committed
[skip ci] Add introductory comment to test_potentially_slicing_shared_ptr.py
1 parent f160450 commit 78178d7

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

tests/test_potentially_slicing_shared_ptr.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2025 The Pybind Development Team.
1+
// Copyright (c) 2025 The pybind Community.
22
// All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

tests/test_potentially_slicing_shared_ptr.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,34 @@
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+
132
from __future__ import annotations
233

334
import gc

0 commit comments

Comments
 (0)