* ci: trying things for Windows Clang failure
Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
* WIP: try using older clang
Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
* tests: skip broken test
Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
* tests: try to skip test in tests
Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
* fix(tests): Prefer __version__ over MSVC
Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
* chore: avoid warning on Clang
Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
* Update tests/test_exceptions.py
* Update tests/test_exceptions.py
---------
Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
* doc: add litgen to the automatic generators list (compiling.rst)
Added this:
[litgen]_ is an automatic python bindings generator with a focus on generating
documented and discoverable bindings: bindings will nicely reproduce the documentation
found in headers. It is is based on srcML (srcml.org), a highly scalable, multi-language
parsing tool with a developer centric approach. The API that you want to expose to python
must be C++14 compatible (but your implementation can use more modern constructs).
.. [litgen] https://pthom.github.io/litgen
* style: pre-commit fixes
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
* stl.h: Use C++11 range-loops with const reference
This saves copy-ctor and dtor for non-trivial types by value
Found by clazy (range-loop-reference)
* test_smart_ptr.cpp cleanup
Introduce `pointer_set<T>`
https://github.com/boostorg/unordered/issues/139
> Based on the standard, the first move should leave a in a "valid but unspecified state";
---------
Co-authored-by: Ralf W. Grosse-Kunstleve <rwgk@google.com>
* fix: Use PyObject_VisitManagedDict() of Python 3.13
Use PyObject_VisitManagedDict() and PyObject_ClearManagedDict() in
pybind11_traverse() and pybind11_clear() on Python 3.13 and newer.
* Add Python 3.13 CI
* tests: don't get numpy/scipy on 3.13 yet
* ci: move 3.13 to upstream
Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
---------
Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
Co-authored-by: Henry Schreiner <HenrySchreinerIII@gmail.com>
* Upgrade maximum supported CMake version to 3.27 to fix warning with CMP0148 policy (#4785)
* Update `macos_brew_install_llvm` pipeline to use expected Python installation
* Fix `Python_EXECUTABLE` Cmake variable typo
* Apply suggestions from code review
* fix: use FindPython for CMake 3.18+ by default for pybind11's tests
Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
* tests: fix issues with finding Python
Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
* tests: also set executable on subdir tests
Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
* fix(cmake): correct logic for FindPython
Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
* Update ci.yml
* Revert "Update ci.yml"
This reverts commit 33798adf3f.
---------
Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
Co-authored-by: Henry Schreiner <HenrySchreinerIII@gmail.com>
* pybind11.pc: use pcfiledir for relative destinations
If the datarootdir is absolute, just use the absolute path directly.
However, if it is relative, we can compute the prefix from the location
of the `.pc` file itself. This allows the install to be relocatable.
* chore: use 3.20's cmake_path if available
* style: pre-commit fixes
* Update CMakeLists.txt
---------
Co-authored-by: Henry Schreiner <HenrySchreinerIII@gmail.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
* fix(cmake): findpython issues and 3.12 support for pybind11_find_import
Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
* Update pybind11NewTools.cmake
---------
Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
* Equivalent of 5718e4d080
* Resolve clang-tidy errors.
* Moving test_PPCCInit() first changes the behavior!
* Resolve new Clang dev C++11 errors:
```
The CXX compiler identification is Clang 17.0.0
```
```
pytypes.h:1615:23: error: identifier '_s' preceded by whitespace in a literal operator declaration is deprecated [-Werror,-Wdeprecated-literal-operator]
```
```
cast.h:1380:26: error: identifier '_a' preceded by whitespace in a literal operator declaration is deprecated [-Werror,-Wdeprecated-literal-operator]
```
* Resolve gcc 4.8.5 error:
```
pytypes.h:1615:12: error: missing space between '""' and suffix identifier
```
* Specifically exclude `__clang__`
* Snapshot of debugging code (does NOT pass pre-commit checks).
* Revert "Snapshot of debugging code (does NOT pass pre-commit checks)."
This reverts commit 1d4f9ff263.
* [ci skip] Order Dependence Demo
* Revert "[ci skip] Order Dependence Demo"
This reverts commit d37b5409d4.
* One way to deal with the order dependency issue. This is not the best way, more like a proof of concept.
* Move test_PC() first again.
* Add `all_type_info_add_base_most_derived_first()`, use in `all_type_info_populate()`
* Revert "One way to deal with the order dependency issue. This is not the best way, more like a proof of concept."
This reverts commit eb09c6c1b9.
* clang-tidy fixes (automatic)
* Add `is_redundant_value_and_holder()` and use to avoid forcing `__init__` overrides when they are not needed.
* Streamline implementation and avoid unsafe `reinterpret_cast<instance *>()` introduced with PR #2152
The `reinterpret_cast<instance *>(self)` is unsafe if `__new__` is mocked,
which was actually found in the wild: the mock returned `None` for `self`.
This was inconsequential because `inst` is currently cast straight back to
`PyObject *` to compute `all_type_info()`, which is empty if `self` is not
a pybind11 `instance`, and then `inst` is never dereferenced. However, the
unsafe detour through `instance *` is easily avoided and the updated
implementation is less prone to accidents while debugging or refactoring.
* Fix actual undefined behavior exposed by previous changes.
It turns out the previous commit message is incorrect, the `inst` pointer is actually dereferenced, in the `value_and_holder` ctor here:
f3e0602802/include/pybind11/detail/type_caster_base.h (L262-L263)
```
259 // Main constructor for a found value/holder:
260 value_and_holder(instance *i, const detail::type_info *type, size_t vpos, size_t index)
261 : inst{i}, index{index}, type{type},
262 vh{inst->simple_layout ? inst->simple_value_holder
263 : &inst->nonsimple.values_and_holders[vpos]} {}
```
* Add test_mock_new()
* Experiment: specify indirect bases
* Revert "Experiment: specify indirect bases"
This reverts commit 4f90d85f9f.
* Add `all_type_info_check_for_divergence()` and some tests.
* Call `all_type_info_check_for_divergence()` also from `type_caster_generic::load_impl<>`
* Resolve clang-tidy error:
```
include/pybind11/detail/type_caster_base.h:795:21: error: the 'empty' method should be used to check for emptiness instead of 'size' [readability-container-size-empty,-warnings-as-errors]
if (matching_bases.size() != 0) {
^~~~~~~~~~~~~~~~~~~~~~~~~~
!matching_bases.empty()
```
* Revert "Resolve clang-tidy error:"
This reverts commit df27188dc6.
* Revert "Call `all_type_info_check_for_divergence()` also from `type_caster_generic::load_impl<>`"
This reverts commit 5f5fd6a68e.
* Revert "Add `all_type_info_check_for_divergence()` and some tests."
This reverts commit 0a9599f775.
* Roundtrip through unique pointer with custom deleter.
Currently failing.
* Ensure the custom deleter is copied back to the unique pointer.
Feels like there's still a gap around the raw pointer flavour, but this at least
makes the unit test of the previous commit succeed.
* Add deleter roundtrip for const atyp.
Currently failing, custom deleter is lost.
* Fix storing deleter for const unique ptr.
Unit test from the previous commit passes.
* Remove SFINEA deleter assignment.
At the construction of the smart holder, it is either a del_fun, or a default constructed deleter, so this complexity is unnecessary.
* Clang format.
* Fixes for ci.
Clang 3.6 requires the extra constructors in the custom_deleter.
* fix(smart_holder): Loosen requirement on deleter to be default constructible.
And some other PR feedback.
* fix(smart_holder): Custom deleter in unit tests traces constructions.
* fix(smart_holder): Use pybind11_fail instead of assert.
* fix(smart_holder): Add unit tests for the default constructible deleter.
* fix(smart_holder): Use regex matching for deleter constructors in unit tests.