Skip to content

Commit 50bb0bf

Browse files
authored
Merge pull request google#30020 from rwgk/pywrapcc_merge_sh
git merge smart_holder
2 parents 53f48d3 + 1d77fb6 commit 50bb0bf

File tree

6 files changed

+29
-5
lines changed

6 files changed

+29
-5
lines changed

include/pybind11/detail/abi_platform_id.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,5 +99,14 @@
9999
/// further ABI-incompatible changes may be made before the ABI is officially
100100
/// changed to the new version.
101101
#ifndef PYBIND11_INTERNALS_VERSION
102-
# define PYBIND11_INTERNALS_VERSION 4
102+
# if PY_VERSION_HEX >= 0x030C0000
103+
// Version bump for Python 3.12+, before first 3.12 beta release.
104+
# define PYBIND11_INTERNALS_VERSION 5
105+
# else
106+
# define PYBIND11_INTERNALS_VERSION 4
107+
# endif
103108
#endif
109+
110+
// This requirement is mainly to reduce the support burden (see PR #4570).
111+
static_assert(PY_VERSION_HEX < 0x030C0000 || PYBIND11_INTERNALS_VERSION >= 5,
112+
"pybind11 ABI version 5 is the minimum for Python 3.12+");

include/pybind11/detail/common.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -844,7 +844,16 @@ template <typename C, typename R, typename... A>
844844
struct remove_class<R (C::*)(A...) const> {
845845
using type = R(A...);
846846
};
847-
847+
#ifdef __cpp_noexcept_function_type
848+
template <typename C, typename R, typename... A>
849+
struct remove_class<R (C::*)(A...) noexcept> {
850+
using type = R(A...);
851+
};
852+
template <typename C, typename R, typename... A>
853+
struct remove_class<R (C::*)(A...) const noexcept> {
854+
using type = R(A...);
855+
};
856+
#endif
848857
/// Helper template to strip away type modifiers
849858
template <typename T>
850859
struct intrinsic_type {

include/pybind11/detail/cross_extension_shared_state.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ PYBIND11_NAMESPACE_BEGIN(detail)
2020

2121
inline object get_python_state_dict() {
2222
object state_dict;
23-
#if (PYBIND11_INTERNALS_VERSION <= 4 && PY_VERSION_HEX < 0x030C0000) \
24-
|| PY_VERSION_HEX < 0x03080000 || defined(PYPY_VERSION)
23+
#if PYBIND11_INTERNALS_VERSION <= 4 || PY_VERSION_HEX < 0x03080000 || defined(PYPY_VERSION)
2524
state_dict = reinterpret_borrow<object>(PyEval_GetBuiltins());
2625
#else
2726
# if PY_VERSION_HEX < 0x03090000

include/pybind11/detail/descr.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ constexpr descr<N, Ts...> concat(const descr<N, Ts...> &descr) {
238238
return descr;
239239
}
240240

241-
#if defined(PYBIND11_CPP17)
241+
#ifdef __cpp_fold_expressions
242242
template <size_t N1, size_t N2, typename... Ts1, typename... Ts2>
243243
constexpr descr<N1 + N2 + 2, Ts1..., Ts2...> operator,(const descr<N1, Ts1...> &a,
244244
const descr<N2, Ts2...> &b) {

tests/test_constants_and_functions.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,4 +148,7 @@ TEST_SUBMODULE(constants_and_functions, m) {
148148
py::arg_v("y", 42, "<the answer>"),
149149
py::arg_v("z", default_value));
150150
});
151+
152+
// test noexcept(true) lambda (#4565)
153+
m.def("l1", []() noexcept(true) { return 0; });
151154
}

tests/test_constants_and_functions.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,7 @@ def __repr__(self):
5050
m.register_large_capture_with_invalid_arguments(m)
5151
with pytest.raises(RuntimeError):
5252
m.register_with_raising_repr(m, RaisingRepr())
53+
54+
55+
def test_noexcept_lambda():
56+
assert m.l1() == 0

0 commit comments

Comments
 (0)