Skip to content

Commit 5bfe727

Browse files
committed
Merge branch 'master' into sh_merge_master
2 parents ec557ff + 2e260b0 commit 5bfe727

16 files changed

+51
-28
lines changed

.clang-tidy

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,12 @@ Checks: |
5757
readability-string-compare,
5858
readability-suspicious-call-argument,
5959
readability-uniqueptr-delete-release,
60+
-bugprone-chained-comparison,
6061
-bugprone-easily-swappable-parameters,
6162
-bugprone-exception-escape,
6263
-bugprone-reserved-identifier,
6364
-bugprone-unused-raii,
65+
-performance-enum-size,
6466
6567
CheckOptions:
6668
- key: modernize-use-equals-default.IgnoreMacros

.github/workflows/ci.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,12 @@ jobs:
341341
- clang: 16
342342
std: 20
343343
container_suffix: "-bullseye"
344+
- clang: 17
345+
std: 20
346+
container_suffix: "-bookworm"
347+
- clang: 18
348+
std: 20
349+
container_suffix: "-bookworm"
344350

345351
name: "🐍 3 • Clang ${{ matrix.clang }} • C++${{ matrix.std }} • x64"
346352
container: "silkeh/clang:${{ matrix.clang }}${{ matrix.container_suffix }}"

.github/workflows/format.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ jobs:
4242
# in .github/CONTRIBUTING.md and update as needed.
4343
name: Clang-Tidy
4444
runs-on: ubuntu-latest
45-
container: silkeh/clang:15-bullseye
45+
container: silkeh/clang:18-bookworm
4646
steps:
4747
- uses: actions/checkout@v4
4848

docs/limitations.rst

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,6 @@ clean, well written patch would likely be accepted to solve them.
5050
One consequence is that containers of ``char *`` are currently not supported.
5151
`#2245 <https://github.com/pybind/pybind11/issues/2245>`_
5252

53-
- The ``cpptest`` does not run on Windows with Python 3.8 or newer, due to DLL
54-
loader changes. User code that is correctly installed should not be affected.
55-
`#2560 <https://github.com/pybind/pybind11/issue/2560>`_
56-
5753
Python 3.9.0 warning
5854
^^^^^^^^^^^^^^^^^^^^
5955

include/pybind11/detail/internals.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -564,7 +564,7 @@ PYBIND11_NOINLINE internals &get_internals() {
564564
}
565565
#endif
566566
internals_ptr->istate = tstate->interp;
567-
state_dict[PYBIND11_INTERNALS_ID] = capsule(internals_pp);
567+
state_dict[PYBIND11_INTERNALS_ID] = capsule(reinterpret_cast<void *>(internals_pp));
568568
internals_ptr->registered_exception_translators.push_front(&translate_exception);
569569
internals_ptr->static_property_type = make_static_property_type();
570570
internals_ptr->default_metaclass = make_default_metaclass();

include/pybind11/detail/type_caster_base.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ PYBIND11_NOINLINE void instance::allocate_layout() {
428428
// NOLINTNEXTLINE(readability-make-member-function-const)
429429
PYBIND11_NOINLINE void instance::deallocate_layout() {
430430
if (!simple_layout) {
431-
PyMem_Free(nonsimple.values_and_holders);
431+
PyMem_Free(reinterpret_cast<void *>(nonsimple.values_and_holders));
432432
}
433433
}
434434

include/pybind11/eigen/tensor.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -469,9 +469,6 @@ struct type_caster<Eigen::TensorMap<Type, Options>,
469469
parent_object = reinterpret_borrow<object>(parent);
470470
break;
471471

472-
case return_value_policy::take_ownership:
473-
delete src;
474-
// fallthrough
475472
default:
476473
// move, take_ownership don't make any sense for a ref/map:
477474
pybind11_fail("Invalid return_value_policy for Eigen Map type, must be either "

include/pybind11/numpy.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -901,7 +901,11 @@ class array : public buffer {
901901

902902
template <typename T>
903903
array(ShapeContainer shape, StridesContainer strides, const T *ptr, handle base = handle())
904-
: array(pybind11::dtype::of<T>(), std::move(shape), std::move(strides), ptr, base) {}
904+
: array(pybind11::dtype::of<T>(),
905+
std::move(shape),
906+
std::move(strides),
907+
reinterpret_cast<const void *>(ptr),
908+
base) {}
905909

906910
template <typename T>
907911
array(ShapeContainer shape, const T *ptr, handle base = handle())
@@ -1986,7 +1990,7 @@ struct vectorize_helper {
19861990
// Pointers to values the function was called with; the vectorized ones set here will start
19871991
// out as array_t<T> pointers, but they will be changed them to T pointers before we make
19881992
// call the wrapped function. Non-vectorized pointers are left as-is.
1989-
std::array<void *, N> params{{&args...}};
1993+
std::array<void *, N> params{{reinterpret_cast<void *>(&args)...}};
19901994

19911995
// The array of `buffer_info`s of vectorized arguments:
19921996
std::array<buffer_info, NVectorized> buffers{

include/pybind11/stl/filesystem.h

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,13 @@
3333
PYBIND11_NAMESPACE_BEGIN(PYBIND11_NAMESPACE)
3434
PYBIND11_NAMESPACE_BEGIN(detail)
3535

36+
#ifdef PYPY_VERSION
37+
# define PYBIND11_REINTERPRET_CAST_VOID_PTR_IF_NOT_PYPY(...) (__VA_ARGS__)
38+
#else
39+
# define PYBIND11_REINTERPRET_CAST_VOID_PTR_IF_NOT_PYPY(...) \
40+
(reinterpret_cast<void *>(__VA_ARGS__))
41+
#endif
42+
3643
#if defined(PYBIND11_HAS_FILESYSTEM) || defined(PYBIND11_HAS_EXPERIMENTAL_FILESYSTEM)
3744
template <typename T>
3845
struct path_caster {
@@ -72,15 +79,17 @@ struct path_caster {
7279
}
7380
PyObject *native = nullptr;
7481
if constexpr (std::is_same_v<typename T::value_type, char>) {
75-
if (PyUnicode_FSConverter(buf, &native) != 0) {
82+
if (PyUnicode_FSConverter(buf, PYBIND11_REINTERPRET_CAST_VOID_PTR_IF_NOT_PYPY(&native))
83+
!= 0) {
7684
if (auto *c_str = PyBytes_AsString(native)) {
7785
// AsString returns a pointer to the internal buffer, which
7886
// must not be free'd.
7987
value = c_str;
8088
}
8189
}
8290
} else if constexpr (std::is_same_v<typename T::value_type, wchar_t>) {
83-
if (PyUnicode_FSDecoder(buf, &native) != 0) {
91+
if (PyUnicode_FSDecoder(buf, PYBIND11_REINTERPRET_CAST_VOID_PTR_IF_NOT_PYPY(&native))
92+
!= 0) {
8493
if (auto *c_str = PyUnicode_AsWideCharString(native, nullptr)) {
8594
// AsWideCharString returns a new string that must be free'd.
8695
value = c_str; // Copies the string.

include/pybind11/stl_bind.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ void vector_modifiers(
180180
v.end());
181181
try {
182182
v.shrink_to_fit();
183-
} catch (const std::exception &) {
183+
} catch (const std::exception &) { // NOLINT(bugprone-empty-catch)
184184
// Do nothing
185185
}
186186
throw;

0 commit comments

Comments
 (0)