Commit Graph

2710 Commits

Author SHA1 Message Date
Steve R. Sun
812293c6a8
Merge branch 'pybind:master' into master 2022-10-09 09:24:10 +08:00
Daniel Galvez
7c6f2f80a7
fix: PyCapsule_GetDestructor is allowed to return a nullptr destructor (#4221)
* fix: PyCapsule_GetDestructor is allowed to return a nullptr destructor

Previously, this code would error out if the destructor happened to be
a nullptr. This is incorrect. nullptrs are allowed for capsule
destructors.

"It is legal for a capsule to have a NULL destructor. This makes a
NULL return code somewhat ambiguous; use PyCapsule_IsValid() or
PyErr_Occurred() to disambiguate."

See:

https://docs.python.org/3/c-api/capsule.html#c.PyCapsule_GetDestructor

I noticed this while working on a type caster related to #3858 DLPack
happens to allow the destructor not to be defined on a capsule, and I
encountered such a case. See:

e2bdd3bee8/include/dlpack/dlpack.h (L219)

* Add test for the fix.

* Update tests/test_pytypes.cpp

I tried this locally and it works!
I never knew that there are cases where `reinterpret_cast` does not work but `static_cast` does. Let's see if all compilers are happy with this.

Co-authored-by: Aaron Gokaslan <skylion.aaron@gmail.com>

* style: pre-commit fixes

Co-authored-by: Ralf W. Grosse-Kunstleve <rwgk@google.com>
Co-authored-by: Ralf W. Grosse-Kunstleve <rwgkio@gmail.com>
Co-authored-by: Aaron Gokaslan <skylion.aaron@gmail.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2022-10-07 12:27:54 -07:00
Ralf W. Grosse-Kunstleve
4a42156209
test_eigen.py test_nonunit_stride_to_python bug fix (ASAN failure) (#4217)
* Disable test triggering ASAN failure (to pin-point where the problem is).

* Fix unsafe "block" implementation in test_eigen.cpp

* Undo changes (i.e. revert back to master).

* Detect "type_caster for Eigen::Ref made a copy."

This is achieved without
* reaching into internals,
* making test_eigen.cpp depend on pybind11/numpy.h.

* Add comment pointing to PR, for easy reference.
2022-10-07 09:20:38 -07:00
Axel Huebl
6cb214748d
fix: NVCC 11.4.0 - 11.8.0 host bug workaround (#4220)
* Work-Around: NVCC 11.4.0 - 11.8.0

Adds a targeted NVCC work around for limited number of CUDA
releases. Fixed in NVCC development.

* style: pre-commit fixes

* CI: Bump CTK Version 11.2 -> 11.7

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2022-10-07 00:02:57 -04:00
Aaron Gokaslan
864ed1120c
chore: steal arg_v.value from copied arg in unpacking_collector (#4219) 2022-10-06 16:11:34 -04:00
Steve R. Sun
77df60021c
Merge branch 'pybind:master' into master 2022-10-06 08:39:11 +08:00
Henry Schreiner
8275b76912
ci: update pre-commit schedule (#4212) 2022-10-04 14:01:26 -04:00
Steve R. Sun
0e7a9d0d24
Merge branch 'pybind:master' into master 2022-10-04 10:38:37 +08:00
pre-commit-ci[bot]
600d697648
[pre-commit.ci] pre-commit autoupdate (#4210)
updates:
- [github.com/pre-commit/mirrors-mypy: v0.971 → v0.981](https://github.com/pre-commit/mirrors-mypy/compare/v0.971...v0.981)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2022-10-03 21:25:46 -04:00
Aaron Gokaslan
c78dfe6964
bugfix: Add error checking to list append and insert (#4208) 2022-10-03 13:44:09 -04:00
Steve R. Sun
155d9924e9
Merge branch 'pybind:master' into master 2022-09-27 09:32:19 +08:00
pre-commit-ci[bot]
da8c730a62
[pre-commit.ci] pre-commit autoupdate (#4197)
updates:
- [github.com/asottile/pyupgrade: v2.38.0 → v2.38.2](https://github.com/asottile/pyupgrade/compare/v2.38.0...v2.38.2)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2022-09-26 20:44:19 -04:00
Steve R. Sun
5f31ef303c
Merge branch 'pybind:master' into master 2022-09-26 08:37:08 +08:00
Aaron Gokaslan
5aa0fad5de
perf: call reserve method in set and map casters (#4194)
* Call reserve method in set and map casters too

* Refactor template logic into has_reserve_method

* Adjust comment for reviews

* Rearrange reserve_maybe to not be underneath macro
2022-09-25 16:10:57 -04:00
Steve R. Sun
8fd14ab4f7
Merge branch 'pybind:master' into master 2022-09-22 09:00:30 +08:00
bogdan-lab
f743bdf8e6
Avoid local_internals destruction (#4192)
* Avoid local_internals destruction

It allows to avoid possible static deinitialization fiasco.

* Add link to relevant google style guide discussion
2022-09-21 11:50:31 -07:00
Aaron Gokaslan
95d0e71a65
test C++14 on MSVC (#4191) 2022-09-21 11:20:07 -04:00
Steve R. Sun
b238590e3b
Merge branch 'pybind:master' into master 2022-09-21 14:27:50 +08:00
Jan Iwaszkiewicz
424ac4fe1b
fix: Windows compiler, missing object initializer (#4188)
* Fix for windows compiler, missing object initializer

* Removal of if-else macro for MSVC
2022-09-20 13:03:57 -04:00
pre-commit-ci[bot]
d02f219fb9
[pre-commit.ci] pre-commit autoupdate (#4189)
updates:
- [github.com/asottile/pyupgrade: v2.37.3 → v2.38.0](https://github.com/asottile/pyupgrade/compare/v2.37.3...v2.38.0)
- [github.com/PyCQA/pylint: v2.15.2 → v2.15.3](https://github.com/PyCQA/pylint/compare/v2.15.2...v2.15.3)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2022-09-19 21:11:57 -04:00
Steve R. Sun
e3fa4294db
Merge branch 'pybind:master' into master 2022-09-20 08:38:11 +08:00
Aaron Gokaslan
9c04c7b0f1
chore: Delete copy ctor/assign for GIL RAIIs (#4183)
* chore: Delete copy ctor/assign for GIL RAIIs

* Fix typo

* Delete copy ops for local gil scoped acquire
2022-09-19 12:56:31 -04:00
Steve R. Sun
02db5fb4a4
Merge branch 'pybind:master' into master 2022-09-15 07:51:23 +08:00
Dustin Spicuzza
1874f8fa87
Clarify GIL documentation (#4057) 2022-09-14 14:00:27 -07:00
Sergei Izmailov
8524b20c3c
fix: Python-3.12 compatibility (#4168)
* fix: Python-3.12 compatibility

Enable dynamic attributes for `pybind11_static_property`

* Add future-notice comment
2022-09-14 13:56:40 -07:00
Steve R. Sun
9e7114b495
Merge branch 'pybind:master' into master 2022-09-13 13:56:36 +08:00
pre-commit-ci[bot]
64f7281874
[pre-commit.ci] pre-commit autoupdate (#4178)
updates:
- [github.com/PyCQA/pylint: v2.15.0 → v2.15.2](https://github.com/PyCQA/pylint/compare/v2.15.0...v2.15.2)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2022-09-12 20:04:44 -04:00
Steve R. Sun
6ed73dc829
Merge branch 'pybind:master' into master 2022-09-08 08:28:54 +08:00
pre-commit-ci[bot]
aa8f8baa4e
[pre-commit.ci] pre-commit autoupdate (#4171)
* [pre-commit.ci] pre-commit autoupdate

updates:
- [github.com/psf/black: 22.6.0 → 22.8.0](https://github.com/psf/black/compare/22.6.0...22.8.0)

* Update .pre-commit-config.yaml

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Henry Schreiner <HenrySchreinerIII@gmail.com>
2022-09-07 09:19:02 -04:00
Steve R. Sun
06345fd3bd
Merge branch 'pybind:master' into master 2022-08-30 16:54:30 +08:00
pre-commit-ci[bot]
8756f16ed8
[pre-commit.ci] pre-commit autoupdate (#4151)
* [pre-commit.ci] pre-commit autoupdate

updates:
- [github.com/Lucas-C/pre-commit-hooks: v1.3.0 → v1.3.1](https://github.com/Lucas-C/pre-commit-hooks/compare/v1.3.0...v1.3.1)
- [github.com/sirosen/texthooks: 0.3.1 → 0.4.0](https://github.com/sirosen/texthooks/compare/0.3.1...0.4.0)
- [github.com/PyCQA/pylint: v2.14.5 → v2.15.0](https://github.com/PyCQA/pylint/compare/v2.14.5...v2.15.0)
- [github.com/codespell-project/codespell: v2.1.0 → v2.2.1](https://github.com/codespell-project/codespell/compare/v2.1.0...v2.2.1)

* Introduce .codespell-ignore-lines for safer (line-based instead of word-based) suppressions.

* Fix two issues: 1. ensure sort order; 2. remove duplicates

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Ralf W. Grosse-Kunstleve <rwgk@google.com>
2022-08-29 21:59:48 -07:00
dependabot[bot]
283f10dc55
chore(deps): bump ilammy/msvc-dev-cmd from 1.10.0 to 1.11.0 (#4161)
Bumps [ilammy/msvc-dev-cmd](https://github.com/ilammy/msvc-dev-cmd) from 1.10.0 to 1.11.0.
- [Release notes](https://github.com/ilammy/msvc-dev-cmd/releases)
- [Commits](https://github.com/ilammy/msvc-dev-cmd/compare/v1.10.0...v1.11.0)

---
updated-dependencies:
- dependency-name: ilammy/msvc-dev-cmd
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-08-29 23:26:53 -04:00
Axel Huebl
0b4c1bc286
test: ConstructorStats newline (PyPy) (#4167)
This looks like it lacks a newline.
2022-08-29 23:25:01 -04:00
Steve R. Sun
a8a90fc7f9
Merge branch 'pybind:master' into master 2022-08-25 09:56:31 +08:00
Ralf W. Grosse-Kunstleve
fac23b6f65
error_fetch_and_normalize: PyPy 7.3.10+ does not need the PR #4079 workaround anymore. (#4154) 2022-08-24 13:08:24 -07:00
Brad Messer
a48ec3e882
Words matter updates (#4155)
* Remove sanity check from code base.

* Use main over master.

* Better alternative that doesn't collide with language keywords/frequent usage words.
2022-08-24 07:34:31 -07:00
Steve R. Sun
e6548251e5
Merge branch 'pybind:master' into master 2022-08-22 09:20:46 +08:00
Ralf W. Grosse-Kunstleve
68e6fdaa90
embed.h Python 3.11 config.use_environment=1 + PYTHONPATH test (#4119)
* Add debug fprintf to test_interpreter.cpp

* Update `sys.path` from `PYTHONPATH` in Python >= 3.11 branch of `initialize_interpreter()`

* Use `config.isolated = 0; config.use_environment = 1;`

As suggsted by @vstinner here: https://github.com/pybind/pybind11/pull/4119#issuecomment-1219442853

* Add `TEST_CASE("PYTHONPATH is used to update sys.path")`

* Fix clang-tidy error.

* Use `_putenv_s()` under Windows.

* Fix clang-tidy error: argument name ... in comment does not match parameter name

* Remove slash from PYTHONPATH addition, to work around Windows slash-vs-backslash issue.

* Use `py::str(...)` instead of `.attr("__str__")` as suggested by @skylion007

Co-authored-by: Aaron Gokaslan <skylion.aaron@gmail.com>

Co-authored-by: Aaron Gokaslan <skylion.aaron@gmail.com>
2022-08-21 09:44:01 -07:00
Steve R. Sun
516a3de044
Merge branch 'pybind:master' into master 2022-08-21 09:29:06 +08:00
Aaron Gokaslan
81f35d29c6
chore: Mark detail:forward_like as constexpr (#4147) 2022-08-20 17:05:07 -04:00
Steve R. Sun
c2f9bcdf7f
Merge branch 'pybind:master' into master 2022-08-13 09:06:46 +08:00
Stephan T. Lavavej
2d59b43cbf
Qualify detail::forward_like to avoid conflict. (#4136)
C++23 feature: P2445R1 forward_like()
2022-08-11 21:19:39 -07:00
Steve R. Sun
7fa86a30db
Merge branch 'pybind:master' into master 2022-08-12 09:49:10 +08:00
Aaron Gokaslan
b884b9dc6b
chore: Add pytests for constructing pytypes from iterable (#4138)
* Add some additional pytests

* Reorder tests

* Further reorder tests

* remove stray lines

* remove unused fixtures
2022-08-11 16:14:17 -04:00
Steve R. Sun
82146ab9ed
Merge branch 'pybind:master' into master 2022-08-10 07:27:17 +08:00
Henry Schreiner
bbb89da152
fix(cmake): support vcpkg, try 2 (#4123)
Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
2022-08-09 00:03:36 -04:00
Eli Schwartz
5bdd3d59be
feat(cmake): add installation support for pkg-config dependency detection (#4077)
* add installation support for pkg-config dependency detection

pkg-config is a buildsystem-agnostic alternative to
`pybind11Config.cmake` that can be used from build systems other than
cmake.

Fixes #230

* tests: add test for pkg config

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

Co-authored-by: Henry Schreiner <henryschreineriii@gmail.com>
2022-08-09 00:02:45 -04:00
Steve R. Sun
56b14f2307
Merge branch 'pybind:master' into master 2022-08-09 09:27:42 +08:00
pre-commit-ci[bot]
14c84654f8
[pre-commit.ci] pre-commit autoupdate (#4126)
updates:
- [github.com/asottile/yesqa: v1.3.0 → v1.4.0](https://github.com/asottile/yesqa/compare/v1.3.0...v1.4.0)
- [github.com/PyCQA/flake8: 5.0.2 → 5.0.4](https://github.com/PyCQA/flake8/compare/5.0.2...5.0.4)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2022-08-08 21:15:43 -04:00
Aaron Gokaslan
6abb7de6cd
chore: Use PyObject_GenericGetDict and PyObject_GenericSetDict functions (#4106)
* Try to update getset_dict APIs for 3.11

* Update API for all Python versions

* Test ifdef for forward explicit forward compat

* Fix ifdef
2022-08-08 14:28:33 -04:00