Commit Graph

3359 Commits

Author SHA1 Message Date
Ralf W. Grosse-Kunstleve
07725c28c0
Introduce pybind11::detail::is_move_constructible (#4631)
To support the use case captured in the new test_vector_unique_ptr_member.cpp
2023-04-24 00:19:21 -07:00
dependabot[bot]
071f35ab85
chore(deps): bump jwlawson/actions-setup-cmake from 1.13 to 1.14 (#4632)
Bumps [jwlawson/actions-setup-cmake](https://github.com/jwlawson/actions-setup-cmake) from 1.13 to 1.14.
- [Release notes](https://github.com/jwlawson/actions-setup-cmake/releases)
- [Commits](https://github.com/jwlawson/actions-setup-cmake/compare/v1.13...v1.14)

---
updated-dependencies:
- dependency-name: jwlawson/actions-setup-cmake
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-04-23 12:32:35 -04:00
Ralf W. Grosse-Kunstleve
6e81be2183
Introduce pybind11::detail::is_move_constructible (#4630)
To support the use case captured in the new test_vector_unique_ptr_member.cpp
2023-04-21 11:30:35 -07:00
Ralf W. Grosse-Kunstleve
d930de0bca
Alternative approach to #3807 (#4612)
* Alternative approach to #3807 that supports an important PyCLIF use case: `Base` not specified in `classh<Derived>` statement, but passing Derived as Base works anyway.

* NOtest_multiple_inheritance_getattr in test_class_sh_void_ptr_capsule.py (quick experiment)

* Revert "NOtest_multiple_inheritance_getattr in test_class_sh_void_ptr_capsule.py (quick experiment)"

This reverts commit e8f0749b89.

* Special handling of pybind11 objects to side-step try_as_void_ptr_capsule_get_pointer __getattr__ issues.

* Inspect `internals.registered_types_py` in `type_is_pybind11_class_()`

* Remove debug code in tests subdir.

* Clean up the modified `try_as_void_ptr_capsule_get_pointer()` implementation and new helper functions.
2023-04-10 11:13:28 -07:00
Ralf W. Grosse-Kunstleve
c6a4191d15 Merge branch 'master' into smart_holder 2023-04-08 11:59:35 -07:00
dependabot[bot]
ed466da571
chore(deps): bump pypa/gh-action-pypi-publish from 1.8.4 to 1.8.5 (#4604)
Bumps [pypa/gh-action-pypi-publish](https://github.com/pypa/gh-action-pypi-publish) from 1.8.4 to 1.8.5.
- [Release notes](https://github.com/pypa/gh-action-pypi-publish/releases)
- [Commits](https://github.com/pypa/gh-action-pypi-publish/compare/v1.8.4...v1.8.5)

---
updated-dependencies:
- dependency-name: pypa/gh-action-pypi-publish
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-04-07 15:52:41 -04:00
Ralf W. Grosse-Kunstleve
fb78376ecd Merge branch 'master' into sh_merge_master 2023-04-06 13:19:17 -07:00
Xiaofei Wang
99cf27a4f5
[smart_holder] Keep parent alive when returning raw pointers (#4609)
* Avoid dangling pointers.

* Add test for const ptr

* Fix test failures.

* Fix ClangTidy

* fix emplace_back
2023-04-06 13:18:05 -07:00
dependabot[bot]
7ab88d2e4f
chore(deps): bump pypa/gh-action-pypi-publish from 1.8.3 to 1.8.4 (#4602)
Bumps [pypa/gh-action-pypi-publish](https://github.com/pypa/gh-action-pypi-publish) from 1.8.3 to 1.8.4.
- [Release notes](https://github.com/pypa/gh-action-pypi-publish/releases)
- [Commits](https://github.com/pypa/gh-action-pypi-publish/compare/v1.8.3...v1.8.4)

---
updated-dependencies:
- dependency-name: pypa/gh-action-pypi-publish
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-04-03 10:18:53 -04:00
Henry Schreiner
4ce05175d5
ci: Python 3.12 optional test job (#4575)
* ci: Python 3.12 optional testing

Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>

* Skip test_flaky_exception_failure_point_init() for Python 3.12.0a6 (similar to af5c6536ab (diff-f46006e3f43ffb1dd5d6862005427f6620f4dcfb1fa2f883d8482550069eeecc)).

* Disable tests/test_embed/test_interpreter.cpp (broken with Python 3.12.0alpha6)

```
free(): invalid pointer

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
test_embed is a Catch v2.13.9 host application.
Run with -? for options

-------------------------------------------------------------------------------
Custom PyConfig
-------------------------------------------------------------------------------
/home/runner/work/pybind11/pybind11/tests/test_embed/test_interpreter.cpp:175
...............................................................................

/home/runner/work/pybind11/pybind11/tests/test_embed/test_interpreter.cpp:179: FAILED:
  {Unknown expression after the reported line}
due to a fatal error condition:
  SIGABRT - Abort (abnormal termination) signal

===============================================================================
test cases:    6 |    5 passed | 1 failed
assertions: 1518 | 1517 passed | 1 failed
```

---------

Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
Co-authored-by: Ralf W. Grosse-Kunstleve <rwgk@google.com>
2023-03-30 10:29:25 -04:00
Ralf W. Grosse-Kunstleve
b37a1cd01d Merge branch 'master' into sh_merge_master 2023-03-27 18:00:01 -07:00
Ralf W. Grosse-Kunstleve
654fe92652
Introduce get_python_state_dict() for Python 3.12 compatibility. (#4570)
* Introduce `get_python_state_dict()`

* Conditional version bump for Python 3.12+

* Shuffle subexpressions to make the condition easier to understand (no change to logic).

* Make pybind11 ABI version 5 the minimum for Python 3.12+ (as suggested by @Lalaland)

* Add back condition for PYPY_VERSION, but keep it open for future PyPy versions.

* Fall back to simple `|| defined(PYPY_VERSION)`. `PY_VERSION_HEX` does not appear to be meaningful with PyPy.
2023-03-27 17:52:57 -07:00
Aaron Gokaslan
1e8b52a9ac
bugfix: allow noexcept lambdas in C++17. Fix #4565 (#4593)
* bugfix: allow noexcept lambdas in CPP17. Fix #4565

* Remove unused code from test case

* Fix clang-tidy error

* Address reviewer comment
2023-03-27 20:21:06 -04:00
Aaron Gokaslan
66f12df03b
chore: make #4587 use proper cpp17 feature macro (#4592) 2023-03-27 10:59:56 -04:00
Ralf W. Grosse-Kunstleve
4f3a1a8231
Add test_class_sh_property_non_owning to CMakeLists.txt (#4590)
* use C++17 syntax to get rid of recursive template instantiations for concatenating type signatures (#4587)

* Apply descr.h `src_loc` change (smart_holder PR #4022) to code added with master PR #4587

* Add test_class_sh_property_non_owning to CMakeLists.txt (fixes oversight in PR #4586)

* Resolve clang-tidy errors.

* clang-tidy auto fix

---------

Co-authored-by: Konstantin Bespalov <kos5tya@yandex.ru>
2023-03-24 00:07:39 -07:00
Ralf W. Grosse-Kunstleve
13936bb258 Apply descr.h src_loc change (smart_holder PR #4022) to code added with master PR #4587 2023-03-23 22:12:13 -07:00
Ralf W. Grosse-Kunstleve
6b8264fb24 Merge branch 'master' into sh_merge_master 2023-03-23 22:05:18 -07:00
Konstantin Bespalov
5bbcba548a
use C++17 syntax to get rid of recursive template instantiations for concatenating type signatures (#4587) 2023-03-23 22:01:09 -07:00
Ralf W. Grosse-Kunstleve
083a03d122 Merge branch 'master' into sh_merge_master 2023-03-23 17:25:43 -07:00
Ralf W. Grosse-Kunstleve
37d0bf4289
[smart_holder] Enable properties for non-owning holders (#4586)
* Add test_class_sh_property_non_owning.cpp,py

Failing:

```
__________________________________________________________ test_persistent_holder __________________________________________________________

    def test_persistent_holder():
        h = m.DataFieldsHolder(2)
>       c = h.vec_at(0).core_fld
E       RuntimeError: Non-owning holder (loaded_as_shared_ptr).

h          = <pybind11_tests.class_sh_property_non_owning.DataFieldsHolder object at 0x7fabab516470>

test_class_sh_property_non_owning.py:6: RuntimeError
__________________________________________________________ test_temporary_holder ___________________________________________________________

    def test_temporary_holder():
        d = m.DataFieldsHolder(2).vec_at(1)
>       c = d.core_fld
E       RuntimeError: Non-owning holder (loaded_as_shared_ptr).

d          = <pybind11_tests.class_sh_property_non_owning.DataField object at 0x7fabab548770>

test_class_sh_property_non_owning.py:13: RuntimeError
```

* Introduce `shared_ptr_from_python(responsible_parent)` and use in all `property_cpp_function`s with `const shared_ptr<T> &` arguments.

Tests are incomplete.

* Complete tests.

* Add comment for `smart_holder_type_caster_load<T>::shared_ptr_from_python`
2023-03-23 17:21:41 -07:00
dependabot[bot]
286873ecf7
chore(deps): bump pypa/gh-action-pypi-publish from 1.8.1 to 1.8.3 (#4584)
Bumps [pypa/gh-action-pypi-publish](https://github.com/pypa/gh-action-pypi-publish) from 1.8.1 to 1.8.3.
- [Release notes](https://github.com/pypa/gh-action-pypi-publish/releases)
- [Commits](https://github.com/pypa/gh-action-pypi-publish/compare/v1.8.1...v1.8.3)

---
updated-dependencies:
- dependency-name: pypa/gh-action-pypi-publish
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-03-23 10:23:52 -04:00
Ralf W. Grosse-Kunstleve
945be5bbd9 Merge branch 'master' into sh_merge_master 2023-03-16 21:36:21 -07:00
Ralf W. Grosse-Kunstleve
cf7d2e6f15
Change always_forkserver_on_unix() to use_multiprocessing_forkserver_on_linux() (#4577) 2023-03-16 14:33:34 -07:00
Henry Schreiner
c4c15d4b10
docs: changelog for 2.10.4 (#4532)
* docs: changelog for 2.10.4

Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>

* Apply suggestions from code review

* Update docs/changelog.rst

---------

Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
2023-03-16 16:01:28 -04:00
dependabot[bot]
04ef4e4229
chore(deps): bump pypa/gh-action-pypi-publish from 1.6.4 to 1.8.1 (#4576) 2023-03-16 18:18:44 +00:00
Ralf W. Grosse-Kunstleve
442261da58
Remove test code that does not exercise anything in pybind11, but breaks between Python 3.12alpha3 (still working) and 3.12alpha6 (broken): (#4559)
```
str(OrderedDict([(1, "a"), (2, "b")]))
```

Old:
```
OrderedDict([(1, 'a'), (2, 'b')])
```

New:
```
OrderedDict({1: 'a', 2: 'b'})
```

See also: https://github.com/python/cpython/issues/101446
2023-03-09 13:02:34 -08:00
pre-commit-ci[bot]
cbb876cc7b
chore(deps): update pre-commit hooks (#4552)
updates:
- [github.com/charliermarsh/ruff-pre-commit: v0.0.251 → v0.0.254](https://github.com/charliermarsh/ruff-pre-commit/compare/v0.0.251...v0.0.254)
- [github.com/PyCQA/pylint: v2.16.1 → v2.16.4](https://github.com/PyCQA/pylint/compare/v2.16.1...v2.16.4)
- [github.com/pre-commit/mirrors-mypy: v0.991 → v1.0.1](https://github.com/pre-commit/mirrors-mypy/compare/v0.991...v1.0.1)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2023-03-07 00:34:41 -05:00
Xiaofei Wang
114c0f2a3e
[smart_holder] Implement try_as_void_ptr_capsule as a free function (#4539)
* Move try_as_void_ptr_capsule out from modified_type_caster_generic_load_impl.

* Try fixing clangtidy
2023-02-28 17:35:21 -08:00
Eli Schwartz
3cc7e4258c
add --version option to pybind11-config (#4526)
Without this, it's impossible to get feature parity between detection
mechanisms. Both the pkg-config file and the cmake config set their
versions, but the python probe script didn't provide an option for this.

So you could print the compiler flags for using it, but you could not
check what you got.
2023-02-22 21:59:14 -08:00
Ralf W. Grosse-Kunstleve
480eb36b3a ubench ruff noqa (in files) 2023-02-22 14:05:23 -08:00
Ralf W. Grosse-Kunstleve
1c10b097a7 test_class_sh_void_ptr_capsule.py manual fixes for ruff 2023-02-22 13:01:46 -08:00
Ralf W. Grosse-Kunstleve
9b78303d7b trivial manual fixes for ruff 2023-02-22 13:00:31 -08:00
Ralf W. Grosse-Kunstleve
cee7cec5f4 ruff auto-fixes (to be reviewed) 2023-02-22 12:46:12 -08:00
Ralf W. Grosse-Kunstleve
e0029bd3b0 ruff: exclude: ubench for now 2023-02-22 12:42:23 -08:00
Ralf W. Grosse-Kunstleve
9005b55bdf Merge branch 'master' into sh_merge_master 2023-02-22 12:32:31 -08:00
Ralf W. Grosse-Kunstleve
9a90783b1e Merge branch 'master' into sh_merge_master 2023-02-22 11:24:43 -08:00
Ralf W. Grosse-Kunstleve
7087a74add Revert "Appease new flake8 B028 error:"
This reverts commit 44c2d89c47.
2023-02-22 11:24:34 -08:00
Henry Schreiner
438034c5b8
chore: move to Ruff and add rules (#4483) 2023-02-22 06:18:55 -08:00
xkszltl
a19daeac16
Inconsistent comments between 2 templates of unchecked(). (#4519)
This comment is unrelated to having T in tparam or not.
Probably a typo.
Copied the correct one here.

Resolve https://github.com/pybind/pybind11/issues/4518
2023-02-20 14:58:37 -08:00
Henry Schreiner
68211d41c1
fix: nicer stack level for warning (#4516)
Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
2023-02-17 17:13:29 -05:00
Ralf W. Grosse-Kunstleve
6a5e6007cd
Make warning suppressions MINGW-specific again. (#4515)
Background: https://github.com/pybind/pybind11/pull/4285#issuecomment-1435066554
2023-02-17 12:58:35 -08:00
Ralf W. Grosse-Kunstleve
d1956eabb5
Appease new flake8 B028 error: (#4513)
```
flake8...................................................................Failed
- hook id: flake8
- exit code: 1

pybind11/setup_helpers.py:177:13: B028 No explicit stacklevel keyword argument found. The warn method from the warnings module uses a stacklevel of 1 by default. This will only show a stack trace for the line on which the warn method is called. It is therefore recommended to use a stacklevel of 2 or greater to provide more information to the user.
            warnings.warn("You cannot safely change the cxx_level after setting it!")
            ^
```
2023-02-17 12:31:08 -08:00
Ralf W. Grosse-Kunstleve
44c2d89c47 Appease new flake8 B028 error:
```
flake8...................................................................Failed
- hook id: flake8
- exit code: 1

pybind11/setup_helpers.py:177:13: B028 No explicit stacklevel keyword argument found. The warn method from the warnings module uses a stacklevel of 1 by default. This will only show a stack trace for the line on which the warn method is called. It is therefore recommended to use a stacklevel of 2 or greater to provide more information to the user.
            warnings.warn("You cannot safely change the cxx_level after setting it!")
            ^
```
2023-02-16 22:43:34 -08:00
Ralf W. Grosse-Kunstleve
bb68819cdf Tracking ci.yml changes from master. 2023-02-16 15:03:38 -08:00
Ralf W. Grosse-Kunstleve
550d4b7490 Merge branch 'master' into sh_merge_master 2023-02-16 15:02:47 -08:00
Ralf W. Grosse-Kunstleve
f7587abb94 Revert "Temporarily remove pip.yml, to avoid GHA failures while waiting for a fix on master."
This reverts commit 3cef809281.
2023-02-16 15:01:45 -08:00
Ralf W. Grosse-Kunstleve
08a4a47a6c
Revert "Go back to CMake 3.25.2 (#4496)" (#4503)
* Revert "Go back to CMake 3.25.2 (#4496)"

This reverts commit b8f28551cc.

* Apply patch provided by @bradking (with pre-commit cmake-format auto fixes).

https://github.com/pybind/pybind11/pull/4503#issuecomment-1424768172
2023-02-16 10:54:57 -05:00
Henry Schreiner
535f81a1c0
fix: tests dir has started to show up in packaging (#4510)
Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
2023-02-16 09:54:27 -05:00
Dustin Spicuzza
8dcced29ae
Always display python type information in cast errors (#4463)
* Always display python type information in cast errors

* Address comments

* Update comment
2023-02-09 21:21:17 -08:00
Mike Essenmacher
531144dddc
Replace "whitelist" with "allowlist" (#4506) 2023-02-09 10:11:01 -08:00