File tree 3 files changed +9
-10
lines changed
3 files changed +9
-10
lines changed Original file line number Diff line number Diff line change @@ -88,20 +88,20 @@ jobs:
88
88
# Extra ubuntu latest job
89
89
- runs-on : ubuntu-latest
90
90
python : ' 3.11'
91
- # Exercise PYBIND11_USE_SMART_HOLDER_AS_DEFAULT
91
+ # Run tests with py::smart_holder as the default holder
92
92
# with recent (or ideally latest) released Python version.
93
93
- runs-on : ubuntu-latest
94
94
python : ' 3.12'
95
95
args : >
96
- -DCMAKE_CXX_FLAGS="-DPYBIND11_USE_SMART_HOLDER_AS_DEFAULT "
96
+ -DCMAKE_CXX_FLAGS="-DPYBIND11_RUN_TESTING_WITH_SMART_HOLDER_AS_DEFAULT_BUT_NEVER_USE_IN_PRODUCTION_PLEASE "
97
97
- runs-on : macos-13
98
98
python : ' 3.12'
99
99
args : >
100
- -DCMAKE_CXX_FLAGS="-DPYBIND11_USE_SMART_HOLDER_AS_DEFAULT "
100
+ -DCMAKE_CXX_FLAGS="-DPYBIND11_RUN_TESTING_WITH_SMART_HOLDER_AS_DEFAULT_BUT_NEVER_USE_IN_PRODUCTION_PLEASE "
101
101
- runs-on : windows-2022
102
102
python : ' 3.12'
103
103
args : >
104
- -DCMAKE_CXX_FLAGS="/DPYBIND11_USE_SMART_HOLDER_AS_DEFAULT /GR /EHsc"
104
+ -DCMAKE_CXX_FLAGS="/DPYBIND11_RUN_TESTING_WITH_SMART_HOLDER_AS_DEFAULT_BUT_NEVER_USE_IN_PRODUCTION_PLEASE /GR /EHsc"
105
105
exclude :
106
106
# The setup-python action currently doesn't have graalpy for windows
107
107
- python : ' graalpy-24.1'
Original file line number Diff line number Diff line change @@ -1839,14 +1839,13 @@ struct property_cpp_function<
1839
1839
detail::both_t_and_d_use_type_caster_base<T, typename D::element_type>>::value>>
1840
1840
: detail::property_cpp_function_sh_unique_ptr_member<T, D> {};
1841
1841
1842
- #if defined(PYBIND11_USE_SMART_HOLDER_AS_DEFAULT)
1843
- // NOTE: THIS IS MEANT FOR STRESS-TESTING ONLY!
1844
- // As of PR #5257, for production use, there is no longer a strong reason to make
1845
- // smart_holder the default holder:
1846
- // Simply use `py::classh` (see below) instead of `py::class_` as needed.
1842
+ #ifdef PYBIND11_RUN_TESTING_WITH_SMART_HOLDER_AS_DEFAULT_BUT_NEVER_USE_IN_PRODUCTION_PLEASE
1843
+ // NOTE: THIS IS MEANT FOR STRESS-TESTING OR TRIAGING ONLY!
1847
1844
// Running the pybind11 unit tests with smart_holder as the default holder is to ensure
1848
1845
// that `py::smart_holder` / `py::classh` is backward-compatible with all pre-existing
1849
1846
// functionality.
1847
+ // Be careful not to link translation units compiled with different default holders, because
1848
+ // this will cause ODR violations (https://en.wikipedia.org/wiki/One_Definition_Rule).
1850
1849
template <typename >
1851
1850
using default_holder_type = smart_holder;
1852
1851
#else
Original file line number Diff line number Diff line change @@ -632,7 +632,7 @@ CHECK_NOALIAS(8);
632
632
CHECK_HOLDER (1 , unique);
633
633
CHECK_HOLDER (2 , unique);
634
634
CHECK_HOLDER (3 , unique);
635
- #ifndef PYBIND11_USE_SMART_HOLDER_AS_DEFAULT
635
+ #ifndef PYBIND11_RUN_TESTING_WITH_SMART_HOLDER_AS_DEFAULT_BUT_NEVER_USE_IN_PRODUCTION_PLEASE
636
636
CHECK_HOLDER (4 , unique);
637
637
CHECK_HOLDER (5 , unique);
638
638
#endif
You can’t perform that action at this time.
0 commit comments