Commit Graph

2165 Commits

Author SHA1 Message Date
Ralf W. Grosse-Kunstleve
1c8795a205 Changing PYBIND11_SMART_HOLDER_TYPE_CASTERS to use __VA_ARGS__. 2021-04-15 10:33:44 -07:00
Ralf W. Grosse-Kunstleve
ab590c624b Disabling deadsnakes 3.10-dev CI (currently broken). 2021-04-14 15:00:56 -07:00
Ralf W. Grosse-Kunstleve
cf89b865bb Adding documentation with associated test: Using py::classh but with fallback to classic pybind11 2021-04-14 15:00:56 -07:00
Ralf W. Grosse-Kunstleve
793adbda50 Revert "Adding documentation with associated test: Using py::classh but with fallback to classic pybind11"
This reverts commit 49f8f60ec4.

The direct commit was accidental. I meant to create a PR.
2021-04-14 12:31:41 -07:00
Ralf W. Grosse-Kunstleve
5f050c4a7e Merge branch 'master' into smart_holder 2021-04-14 12:21:49 -07:00
Ralf W. Grosse-Kunstleve
49f8f60ec4 Adding documentation with associated test: Using py::classh but with fallback to classic pybind11 2021-04-14 12:19:15 -07:00
Philipp Bucher
62976cfcb8
fix: using -Werror-all for Intel (#2948)
* correcting Werror for Intel

* adding ward for Intel

* adding wards for intel

* another ward for Intel

* missed one intel ward

* exact match for intel compiler

* removing inline limits

* disable warnings about inline limits

* formatter suggestion

* more indent

* hopefully make formatter happy

* addressed review

* fix &&

* Update tests/CMakeLists.txt

Co-authored-by: Henry Schreiner <HenrySchreinerIII@gmail.com>

Co-authored-by: Henry Schreiner <HenrySchreinerIII@gmail.com>
2021-04-14 14:01:27 -04:00
Ralf W. Grosse-Kunstleve
e9ae11f9ef Merge branch 'master' into smart_holder 2021-04-13 17:08:30 -07:00
Tamaki Nishino
6709abba93
Allow function pointer extraction from overloaded functions (#2944)
* Add a failure test for overloaded functions

* Allow function pointer extraction from overloaded functions
2021-04-13 16:53:56 -07:00
Ralf W. Grosse-Kunstleve
4aab10a2d3 Merge branch 'master' into smart_holder 2021-04-13 05:35:28 -07:00
Ralf W. Grosse-Kunstleve
8efd5e3820
Bug fix: trampoline_self_life_support CpCtor, MvCtor. (#2947) 2021-04-13 05:34:46 -07:00
Henry Schreiner
e0c1dadb75
chore: add myself to CODEOWNERS (#2940)
* chore: add myself to CODEOWNERS

This will ensure I get notified about pull requests where these files change.

* Update .github/CODEOWNERS
2021-04-10 11:12:56 -04:00
Ralf W. Grosse-Kunstleve
6c922614ed
Adding reclaim_disowned logic & miscellaneous naming and documentation improvements. (#2943)
* Using new smart_holder::reclaim_disowned in smart_holder_type_caster for unique_ptr.

* Systematically renaming was_disowned to is_disowned (because disowning is now reversible: reclaim_disowned).

* Systematically renaming virtual_overrider_self_life_support to trampoline_self_life_support (to reuse existing terminology instead of introducing new one).

* Systematically renaming test_class_sh_with_alias to test_class_sh_trampoline_basic.

* Adding a Trampolines and std::unique_ptr section to README_smart_holder.rst.

* MSVC compatibility.
2021-04-09 23:08:44 -07:00
Ralf W. Grosse-Kunstleve
88a09988e7 Merge branch 'master' into smart_holder 2021-04-08 23:17:31 -07:00
Ralf W. Grosse-Kunstleve
2b4fbbd521
Bug fix for virtual_overrider_self_life_support ASAN heap-use-after-free failure. (#2942)
* Porting subset of absltest code from reproducer provided by @elkhrt. Baseline for debugging ASAN heap-use-after-free.

* Moving Py_DECREF to resolve ASAN heap-use-after-free failure.

* Fixing trivial formatting issue.

* Workaround for clang 3.6 and 3.7.
2021-04-08 22:56:46 -07:00
Weiming Zhao
4f0727f280
Fix the enabling of default extension handling (#2938) 2021-04-05 23:50:50 -04:00
dependabot[bot]
16c23fef31
chore(deps): bump pre-commit/action from v2.0.0 to v2.0.2 (#2935) 2021-04-05 22:53:59 -04:00
Ralf W. Grosse-Kunstleve
7eb6d6f695 Removing capsys.disable() in test_class_sh_disowning.py.
It was only useful for easily harvest this from the GitHub Actions CI results, mostly out of curiosity:

52 C++ function argument 1 is evaluated first.
90 C++ function argument 2 is evaluated first.

These results came for the final CI run for PR #2936; that PR has nothing else to do with the results.

Pushing directly. This tiny change is not worth a PR.

[skip actions]
2021-04-05 18:07:11 -07:00
Ralf W. Grosse-Kunstleve
71603042d2 Fixing very minor oversights discovered while proof-reading the initial version for the first time on GitHub. Pushing directly. Not worth a PR. 2021-04-05 14:02:08 -07:00
Ralf W. Grosse-Kunstleve
0b63dd0eb2
Adding initial README_smart_holder.rst. (#2936)
* Adding initial README_smart_holder.rst.

* Adding README_smart_holder.rst to MANIFEST.in and test_files.py.
2021-04-05 13:47:48 -07:00
Ralf W. Grosse-Kunstleve
2f624af1ac Merge branch 'master' into smart_holder 2021-04-02 18:20:27 -07:00
Ralf W. Grosse-Kunstleve
ad6bf5cd39
Adding PyGILState_Check() in object_api<>::operator(). (#2919)
* Adding PyGILState_Check() in object_api<>::operator().

* Enabling PyGILState_Check() for Python >= 3.6 only.

Possibly, this explains why PyGILState_Check() cannot safely be used with Python 3.4 and 3.5:

https://github.com/python/cpython/pull/10267#issuecomment-434881587

* Adding simple micro benchmark.

* Reducing test time to minimum (purely for coverage, not for accurate results).

* Fixing silly oversight.

* Minor code organization improvement in test.

* Adding example runtimes.

* Removing capsys (just run with `-k test_callback_num_times -s` and using `.format()`.
2021-04-02 18:17:12 -07:00
Ralf W. Grosse-Kunstleve
488014076b Merge branch 'master' into smart_holder 2021-04-02 11:36:35 -07:00
Eric Cousineau
f676782bec
env: Add surrogate for pytest.deprecated_call for ptyest<3.9 (#2923)
env: Add surrogate for pytest.deprecated_call for ptyest<3.9
2021-04-02 14:34:09 -04:00
Jerome Robert
1259db6fd9
Fix Pybind11Extension on mingw64 (#2921)
* Pybind11Extension add the "/EHsc /bigobj /std:c++14" flags on Windows.
  This is good for Visual C++ but not for Mingw.
* According
  https://github.com/msys2/MINGW-packages/blob/master/mingw-w64-python2/0410-MINGW-build-extensions-with-GCC.patch
  sysconfig.get_platform() is the way to check for a Mingw64
2021-04-02 10:26:17 -07:00
Robert Haschke
c2db53da56
fix: catch missing self argument in overloads constructor (#2914) 2021-04-02 13:13:44 -04:00
JYX
3df0ee6fe3
docs: typo in classes.rst (#2926) 2021-04-02 11:46:43 -04:00
Ralf W. Grosse-Kunstleve
3108eb9d33
Adding tests to test_class_sh_disowning_mi for expanded coverage. (#2918)
* Adding tests to test_class_sh_disowning_mi for expanded coverage.

* Setting @pytest.mark.xfail strict=False (some tests pass with PyPy, some don't).
2021-03-25 09:08:57 -07:00
Ralf W. Grosse-Kunstleve
eb7b61d492
Adding test_class_sh_disowning_mi.cpp (multiple inheritance). (#2917) 2021-03-23 16:25:14 -07:00
Ralf W. Grosse-Kunstleve
08339d6331
Adding tests to exercise corner cases involving disowning. (#2912)
* Adding test_class_sh_disowning.

* Fixing minor namespace naming inconsistency between test_class_sh_*.cpp files.

* Replacing py::overload_cast with plain cast for C++11 compatibility.

* Accommodate that the C++ order of evaluation of function arguments is unspecified.
2021-03-22 12:16:29 -07:00
Ralf W. Grosse-Kunstleve
5319ca3817
Using dynamic_cast<AliasType> to determine pointee_depends_on_holder_owner. (#2910)
* Adaption of PyCLIF virtual_py_cpp_mix test.

* Removing ValueError: Ownership of instance with virtual overrides in Python cannot be transferred to C++. TODO: static_assert alias class needs to inherit from virtual_overrider_self_life_support.

* Bringing back ValueError: "... instance cannot safely be transferred to C++.", but based on dynamic_cast<AliasType>.

* Fixing oversight: adding test_class_sh_virtual_py_cpp_mix.cpp to cmake file.

* clang <= 3.6 compatibility.

* Fixing oversight: dynamic_raw_ptr_cast_if_possible needs special handling for To = void. Adding corresponding missing test in test_class_sh_virtual_py_cpp_mix. Moving dynamic_raw_ptr_cast_if_possible to separate header.

* Changing py::detail::virtual_overrider_self_life_support to py::virtual_overrider_self_life_support.
2021-03-19 12:18:39 -07:00
Ralf W. Grosse-Kunstleve
3f35af7441 Adding smart_holder branch to workflow_dispatch in all places where stable appears. 2021-03-18 11:29:22 -07:00
Ralf W. Grosse-Kunstleve
62a8d35831 Fixing oversight: clang-format pybind11.h (affecting smart_holder code only). 2021-03-18 11:23:14 -07:00
Ralf W. Grosse-Kunstleve
245d31cb03
Renaming PYBIND11_SMART_POINTER_HOLDER_TYPE_CASTERS to PYBIND11_TYPE_CASTER_BASE_HOLDER. (#2907) 2021-03-17 04:56:11 -07:00
Ralf W. Grosse-Kunstleve
2ada792085 Pure clang-format cleanup (after #2904), NO other changes. 2021-03-17 03:52:43 -07:00
Robert Haschke
784092dfd2
Missing cast from const unique_ptr& (#2904)
* Add roundtrip tests for unique_ptr

* Implementation for casting from const std::unique_ptr&

... forwarding to smart_holder_type_caster<T>::cast(T*)
2021-03-16 18:10:12 -07:00
Ralf W. Grosse-Kunstleve
469792032a
Adding virtual_overrider_self_life_support. (#2902)
* Initial version of virtual_overrider_self_life_support (enables safely passing unique_ptr to C++).

* Clang 3.6, 3.7 compatibility.

* Adding missing default constructor.

* Restoring test for exception for the case that virtual_overrider_self_life_support is not used.

* Fixing oversight: Adding missing holder().ensure_was_not_disowned().

* Adding unit tests for new `struct smart_holder` member functions.

* Moving virtual_overrider_self_life_support to separate include file, with iwyu cleanup.
2021-03-16 06:31:24 -07:00
Ralf W. Grosse-Kunstleve
d6cf6dfed3 Merge branch 'master' into smart_holder 2021-03-09 15:11:35 -08:00
Ralf W. Grosse-Kunstleve
0e01c243c7
Generalizing suppression for pypocketfft. (#2896)
* Adding suppression for pypocketfft.

* Generalize existing pypocketfft Valgrind suppression

Co-authored-by: Yannick Jadoul <yannick.jadoul@belgacom.net>
2021-03-09 15:07:44 -08:00
Boris Staletic
f110889dde
Use correct duration representation when casting from datetime.timdelta to std::chrono::duration (#2870)
* Use correct duration representation when casting from datetime.timdelta to std::chrono::duration

* When asserting datetime/timedelta/date/time we can equality-compare whole objects
2021-03-07 23:42:01 -08:00
Ralf W. Grosse-Kunstleve
61f66e256e Merge branch 'master' into smart_holder 2021-03-06 20:08:09 -08:00
Ralf W. Grosse-Kunstleve
44678e5476
Shuffling code in test_multiple_inheritance.cpp to separate struct/class definitions from bindings code. (#2890) 2021-03-05 17:45:57 -05:00
Ralf W. Grosse-Kunstleve
dbcb6d3a9f Moving prune ubench to the top, to avoid merge conflict with the RobotLocomotion drake branch. 2021-03-05 12:17:20 -08:00
Ralf W. Grosse-Kunstleve
97a7fb722a
Porting/adapting Dustin's PR #2839 to smart_holder branch (#2886)
* WIP: test setup complete, AddInCppUniquePtr failing (reproduces PyCLIF smart_ptrs_test failure).

* Fully tested locally.

* Adding new tests to cmake file.
2021-03-03 17:58:42 -08:00
Ralf W. Grosse-Kunstleve
6a7e9f42fe
Changing all but one std::runtime_error to std::invalid_argument, which appears as ValueError in the Python interpreter. Adding test_cannot_disown_use_count_ne_1. (#2883) 2021-03-03 05:08:47 -08:00
Ralf W. Grosse-Kunstleve
3a336a2047
shared_ptr<bool> vptr_deleter_armed_flag_ptr (instead of unique_ptr) (#2882)
* shared_ptr<bool> vptr_deleter_armed_flag_ptr (instead of unique_ptr), to fix heap-use-after-free bug.

* Fixing  generated by some compilers in the pybind11 CI suite.
2021-03-02 17:43:25 -08:00
Ralf W. Grosse-Kunstleve
6285177afe Undoing accidental commit (this was meant to go to a new branch).
Revert "WIP: test setup complete, AddInCppUniquePtr failing (reproduces PyCLIF smart_ptrs_test failure)."

This reverts commit 20107030ab.
2021-02-27 08:59:43 -08:00
Ralf W. Grosse-Kunstleve
20107030ab WIP: test setup complete, AddInCppUniquePtr failing (reproduces PyCLIF smart_ptrs_test failure). 2021-02-27 08:55:04 -08:00
Ralf W. Grosse-Kunstleve
666fc0d8e8
Changing cast_error("... Python instance was disowned.") to value_error (which changes RuntimeError to ValueError). (#2880) 2021-02-26 23:19:23 -08:00
Ralf W. Grosse-Kunstleve
01e0045547
Enabling use of smart_holder for types with non-public destructors. (#2878)
* Enabling use of smart_holder for types with non-public destructors.

* Resolving clang-tidy error (GitHub CI).
2021-02-26 17:51:50 -08:00