Commit Graph

840 Commits

Author SHA1 Message Date
Ralf W. Grosse-Kunstleve d5e302ce46 Removing uses of env.PY2 and env.PY (no longer available).
smart_holder_type_casters.h tweaks:
    * Removing MSVC 2015 workaround.
    * Manually adding braces to pre-empt clang-tidy issue (involving `#ifdef`).
    * Removing `// clang-format off` & `on`.
    * One manual line break (moving comment above line).

Adding mypy type information for ubench/*.py
2022-02-14 18:51:58 -08:00
Ralf W. Grosse-Kunstleve e1751c04f0 Merge branch 'master' into sh_merge_master_after_clang-format_etc
First pass manually resolving the many merge conflicts.
2022-02-14 14:36:08 -08:00
Ralf W. Grosse-Kunstleve a97e9d8cac
Dropping MSVC 2015 (#3722)
* Changing `_MSC_VER` guard to `< 1910` (dropping MSVC 2015).

* Removing MSVC 2015 from ci.yml, and .appveyor.yml entirely.

* Bringing back .appveyor.yml from master.

* appveyor Visual Studio 2017

* 1st manual pass, builds & tests with unix_clang, before pre-commit.

* After clang-format (via pre-commit).

* Manual pass looking for "2015", builds & tests with unix_clang, before pre-commit.

* Backtracking for include/pybind11 changes in previous commit.

git checkout d07865846c include/pybind11/attr.h include/pybind11/detail/common.h include/pybind11/functional.h

--------------------

CI #4160 errors observed:

2a26873727
https://github.com/pybind/pybind11/runs/5168332130?check_suite_focus=true

$ grep ' error C' *.txt | sed 's/2022-02-12[^ ]*//' | sed 's/^[0-9][0-9]*//' | sed 's/^.*\.txt: //' | sort | uniqD:\a\pybind11\pybind11\include\pybind11\cast.h(1364,1): error C2752: 'pybind11::detail::type_caster<Eigen::Ref<Eigen::Vector3f,0,pybind11::EigenDStride>,void>': more than one partial specialization matches the template argument list [D:\a\pybind11\pybind11\build\tests\pybind11_tests.vcxproj]

d:\a\pybind11\pybind11\include\pybind11\detail/common.h(1023): error C2737: 'pybind11::overload_cast': 'constexpr' object must be initialized [D:\a\pybind11\pybind11\build\tests\cross_module_gil_utils.vcxproj]
d:\a\pybind11\pybind11\include\pybind11\detail/common.h(1023): error C2737: 'pybind11::overload_cast': 'constexpr' object must be initialized [D:\a\pybind11\pybind11\build\tests\pybind11_cross_module_tests.vcxproj]
d:\a\pybind11\pybind11\include\pybind11\detail/common.h(1023): error C2737: 'pybind11::overload_cast': 'constexpr' object must be initialized [D:\a\pybind11\pybind11\build\tests\pybind11_tests.vcxproj]
d:\a\pybind11\pybind11\include\pybind11\detail/common.h(1023): error C2737: 'pybind11::overload_cast': 'constexpr' object must be initialized [D:\a\pybind11\pybind11\build\tests\test_embed\external_module.vcxproj]
D:\a\pybind11\pybind11\include\pybind11\detail/common.h(624): fatal error C1001: Internal compiler error. [D:\a\pybind11\pybind11\build\tests\pybind11_tests.vcxproj]
D:\a\pybind11\pybind11\include\pybind11\detail/common.h(624): fatal error C1001: Internal compiler error. [D:\a\pybind11\pybind11\tests\pybind11_tests.vcxproj]

$ grep ': error C2737' *.txt | sed 's/^.*MSVC//' | sed 's/___.*//' | sort | uniq

_2017

$ grep ': error C2752' *.txt

3______3.8_____MSVC_2019_____x86_-DCMAKE_CXX_STANDARD=17.txt:2022-02-12T16:12:45.9921122Z D:\a\pybind11\pybind11\include\pybind11\cast.h(1364,1): error C2752: 'pybind11::detail::type_caster<Eigen::Ref<Eigen::Vector3f,0,pybind11::EigenDStride>,void>': more than one partial specialization matches the template argument list [D:\a\pybind11\pybind11\build\tests\pybind11_tests.vcxproj]

$ grep ': fatal error C1001:' *.txt

10______pypy-3.8-v7.3.7_____windows-2022_____x64.txt:2022-02-12T16:12:56.3163683Z D:\a\pybind11\pybind11\include\pybind11\detail/common.h(624): fatal error C1001: Internal compiler error. [D:\a\pybind11\pybind11\tests\pybind11_tests.vcxproj]
1______3.6_____MSVC_2019_____x86.txt:2022-02-12T16:12:47.6774625Z D:\a\pybind11\pybind11\include\pybind11\detail/common.h(624): fatal error C1001: Internal compiler error. [D:\a\pybind11\pybind11\build\tests\pybind11_tests.vcxproj]
16______3.6_____windows-latest_____x64_-DPYBIND11_FINDPYTHON=ON.txt:2022-02-12T16:12:27.0556151Z D:\a\pybind11\pybind11\include\pybind11\detail/common.h(624): fatal error C1001: Internal compiler error. [D:\a\pybind11\pybind11\tests\pybind11_tests.vcxproj]
17______3.9_____windows-2019_____x64.txt:2022-02-12T16:12:30.3822566Z D:\a\pybind11\pybind11\include\pybind11\detail/common.h(624): fatal error C1001: Internal compiler error. [D:\a\pybind11\pybind11\tests\pybind11_tests.vcxproj]
2______3.7_____MSVC_2019_____x86.txt:2022-02-12T16:12:38.7018911Z D:\a\pybind11\pybind11\include\pybind11\detail/common.h(624): fatal error C1001: Internal compiler error. [D:\a\pybind11\pybind11\build\tests\pybind11_tests.vcxproj]
6______3.6_____windows-2022_____x64.txt:2022-02-12T16:12:00.4513642Z D:\a\pybind11\pybind11\include\pybind11\detail/common.h(624): fatal error C1001: Internal compiler error. [D:\a\pybind11\pybind11\tests\pybind11_tests.vcxproj]
7______3.9_____windows-2022_____x64.txt:2022-02-12T16:11:43.6306160Z D:\a\pybind11\pybind11\include\pybind11\detail/common.h(624): fatal error C1001: Internal compiler error. [D:\a\pybind11\pybind11\tests\pybind11_tests.vcxproj]
8______3.10_____windows-2022_____x64.txt:2022-02-12T16:11:49.9589644Z D:\a\pybind11\pybind11\include\pybind11\detail/common.h(624): fatal error C1001: Internal compiler error. [D:\a\pybind11\pybind11\tests\pybind11_tests.vcxproj]
9______pypy-3.7-v7.3.7_____windows-2022_____x64.txt:2022-02-12T16:11:53.7912112Z D:\a\pybind11\pybind11\include\pybind11\detail/common.h(624): fatal error C1001: Internal compiler error. [D:\a\pybind11\pybind11\tests\pybind11_tests.vcxproj]

* common.h: is_template_base_of

* Re-applying 4 changes from 2a26873727 that work universally.

* `overload_cast = {};` only for MSVC 2017 and Clang 5

* Refining condition for using is_template_base_of workaround.

* Undoing MSVC 2015 workaround in test_constants_and_functions.cpp

* CentOS7: silence_unused_warnings

* Tweaks in response to reviews.

* Adding windows-2022 C++20

* Trying another way of adding windows-2022 C++20
2022-02-14 11:36:22 -08:00
Henry Schreiner 522c59ceb2
chore: drop Python 3.5 (#3719)
* chore: drop Python 3.5 support

* chore: more fstrings with flynt's help

* ci: drop Python 3.5

* chore: bump dependency versions

* docs: touch up py::args

* tests: remove deprecation warning

* Ban smartquotes

* Very minor tweaks (by-product of reviewing PR #3719).

Co-authored-by: Aaron Gokaslan <skylion.aaron@gmail.com>
Co-authored-by: Ralf W. Grosse-Kunstleve <rwgk@google.com>
2022-02-11 19:06:16 -05:00
Chris Ohk 1a432b426f
docs: Correct minor typos (#3721) 2022-02-11 10:42:48 -05:00
Ralf W. Grosse-Kunstleve 6493f496e3
Python 2 removal part 1: tests (C++ code is intentionally ~untouched) (#3688)
* `#error BYE_BYE_GOLDEN_SNAKE`

* Removing everything related to 2.7 from ci.yml

* Commenting-out Centos7

* Removing `PYTHON: 27` from .appveyor.yml

* "PY2" removal, mainly from tests. C++ code is not touched.

* Systematic removal of `u` prefix from `u"..."` and `u'...'` literals. Collateral cleanup of a couple minor other things.

* Cleaning up around case-insensitive hits for `[^a-z]py.*2` in tests/.

* Removing obsolete Python 2 mention in compiling.rst

* Proper `#error` for Python 2.

* Using PY_VERSION_HEX to guard `#error "PYTHON 2 IS NO LONGER SUPPORTED.`

* chore: bump pre-commit

* style: run pre-commit for pyupgrade 3+

* tests: use sys.version_info, not PY

* chore: more Python 2 removal

* Uncommenting Centos7 block (PR #3691 showed that it is working again).

* Update pre-commit hooks

* Fix pre-commit hook

* refactor: remove Python 2 from CMake

* refactor: remove Python 2 from setup code

* refactor: simplify, better static typing

* feat: fail with nice messages

* refactor: drop Python 2 C++ code

* docs: cleanup for Python 3

* revert: intree

revert: intree

* docs: minor touchup to py2 statement

Co-authored-by: Henry Schreiner <henryschreineriii@gmail.com>
Co-authored-by: Aaron Gokaslan <skylion.aaron@gmail.com>
2022-02-10 18:28:08 -08:00
Ralf W. Grosse-Kunstleve ec24786eab
Fully-automatic clang-format with include reordering (#3713)
* chore: add clang-format

* Removing check-style (Classic check-style)

Ported from @henryiii's 53056b1b0e

* Automatic clang-format changes (NO manual changes).

Co-authored-by: Henry Schreiner <henryschreineriii@gmail.com>
2022-02-10 12:17:07 -08:00
Ralf W. Grosse-Kunstleve e96221beff
Final manual curation in preparation for global `clang-format`ing (#3712)
* Manual line breaks to pre-empt undesired `clang-format`ing.

Informed by work under https://github.com/pybind/pybind11/pull/3683:

60b7eb410f

59572e6559

* Manual curation of clang-format diffs involving source code comments.

Very labor-intensive and dull.

* Pulling .clang-format change from @henryiii's 9057962d40

* Adding commonly used .clang-format `CommentPragmas:`

* Ensure short lambdas are allowed

Co-authored-by: Aaron Gokaslan <skylion.aaron@gmail.com>
2022-02-10 11:42:03 -08:00
Aaron Gokaslan d6c66d25bb
chore(clang-tidy): Add clang-tidy rules: prefer-member-initializer and optin.performance.Padding (#3716)
* Add clang-tidy prefer-member-initializer

* Fix clang-tdy config

* Fix incorrect change

* Fix sorting of .clang-tidy
2022-02-10 09:45:46 -08:00
Aaron Gokaslan dc9803cef2
Add missing clang-tidy fixes (#3715) 2022-02-10 09:23:15 -08:00
Ralf W. Grosse-Kunstleve abc38690dc
Manually applying two clang-format changes that need fix-ups for clang-tidy. (#3705) 2022-02-09 06:32:41 -08:00
Ralf W. Grosse-Kunstleve 7769e7719c
clang-tidy readability-qualified-auto (#3702)
* Adding readability-qualified-auto to .clang-tidy

Ported from @henryiii's 287527f705

* fix: support Python < 3.6

Co-authored-by: Henry Schreiner <henryschreineriii@gmail.com>
2022-02-09 06:24:57 -08:00
Ralf W. Grosse-Kunstleve ddbc74c674 Adding .clang-tidy readability-braces-around-statements option.
clang-tidy automatic changes. NO manual changes.
2022-02-08 13:02:20 -08:00
Michał Górny 96b943be1d
tests: update catch to 2.13.5 to fix glibc 2.34 failures (#3679)
* Download catch for MinGw

* Fix rest of MinGW

* fix: update catch to 2.13.5 to fix glibc 2.34 failures

Update the downloaded Catch version to 2.13.5, in order to fix build
failure on glibc 2.34:

```
In file included from /usr/include/signal.h:328,
                 from /tmp/pybind11/.nox/tests-3-9/tmp/tests/catch/catch.hpp:8030,
                 from /tmp/pybind11/tests/test_embed/catch.cpp:13:
/tmp/pybind11/.nox/tests-3-9/tmp/tests/catch/catch.hpp:10818:58: error: call to non-‘constexpr’ function ‘long int sysconf(int)’
10818 |     static constexpr std::size_t sigStackSize = 32768 >= MINSIGSTKSZ ? 32768 : MINSIGSTKSZ;
      |                                                          ^~~~~~~~~~~
In file included from /usr/include/python3.9/Python.h:36,
                 from /tmp/pybind11/include/pybind11/detail/common.h:215,
                 from /tmp/pybind11/include/pybind11/pytypes.h:12,
                 from /tmp/pybind11/include/pybind11/cast.h:13,
                 from /tmp/pybind11/include/pybind11/attr.h:13,
                 from /tmp/pybind11/include/pybind11/pybind11.h:13,
                 from /tmp/pybind11/include/pybind11/embed.h:12,
                 from /tmp/pybind11/tests/test_embed/catch.cpp:4:
/usr/include/unistd.h:640:17: note: ‘long int sysconf(int)’ declared here
  640 | extern long int sysconf (int __name) __THROW;
      |                 ^~~~~~~
In file included from /tmp/pybind11/tests/test_embed/catch.cpp:13:
/tmp/pybind11/.nox/tests-3-9/tmp/tests/catch/catch.hpp:10877:45: error: size of array ‘altStackMem’ is not an integral constant-expression
10877 |     char FatalConditionHandler::altStackMem[sigStackSize] = {};
      |                                             ^~~~~~~~~~~~
```

The newest Catch version cannot be used yet because of regression:
https://github.com/catchorg/Catch2/pull/2364

* fix: add option for _ check, only define on pybind11

* Revert "fix: add option for _ check, only define on pybind11"

This reverts commit 86817db488.

* fix: only undef _ for catch cpp creation.

Co-authored-by: Aaron Gokaslan <skylion.aaron@gmail.com>
Co-authored-by: Henry Schreiner <henryschreineriii@gmail.com>
2022-02-05 23:53:02 -05:00
Ralf W. Grosse-Kunstleve 4070a64f86 Merge branch 'master' into sh_merge_master 2022-02-03 15:07:04 -08:00
Michał Górny 1d3b04e805
test: Strip whitespace when comparing numpy dtypes for 1.22 compat (#3682)
* test: Strip whitespace when comparing numpy dtypes for 1.22 compat

Strip whitespace when comparing numpy dtype str() in order to preserve
test compatibility with both numpy 1.22 and older versions whose output
differ by whitespace.

Fixes #3680

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2022-02-03 12:29:46 -05:00
Aaron Gokaslan 3a8d92308d
Fix caster optimization regression introduced in #3650 (#3659)
* Fix optimization bug introduced in #3650

* Add simple Python extension test for MVF

* Improve comments

* Clarify comment

* Clarify another comment

* Add test docstring

* Fix typo
2022-01-31 12:19:48 -05:00
Ralf W. Grosse-Kunstleve aa4fe8e4ff Merge branch 'master' into sh_merge_master 2022-01-26 19:08:58 -08:00
Dustin Spicuzza ec81e8e778
Propagate py::multiple_inheritance to all children (#3650)
* Add tests demonstrating smart_holder issues with multiple inheritance

* Propagate C++ multiple inheritance markers to all children

- Makes py::multiple_inheritance only needed in base classes hidden from pybind11
2022-01-26 17:03:52 -08:00
Xiaofei Wang 93a376a40a
[smart_holder] Add missing test case to CMakeLists.txt (#3645)
* Add missing test case to CMakeLists.txt

* Fix warnings

* Fix Clangtidy
2022-01-25 16:43:11 -08:00
Xiaofei Wang da058a2904
[Smart holder] Support void pointer capsules (#3633)
* Make smart holder type casters support void pointer capsules.

* Fix warnings

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Fix checks

* Fix check failures under CentOS

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Remove unused regex module

* Resolve comments

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Resolve comments

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Fix clangtidy

* Resolve comments

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2022-01-25 13:29:54 -08:00
Ralf W. Grosse-Kunstleve 152bb100f2 Merge branch 'master' into sh_merge_master 2022-01-16 07:07:12 -08:00
Sergei Izmailov 5194855900
Render `py::bool_` and `py::float_` without `_` in docstrings (#3622)
* Render `py::bool_` as `bool` in docstrings

* Render `py::float_` as `float` in docstrings
2022-01-16 07:05:46 -08:00
Ralf W. Grosse-Kunstleve c8d36b3c99 Merge branch 'master' into sh_merge_master 2022-01-14 23:17:11 -08:00
Aaron Gokaslan d2ec836712
Add support for nested C++11 exceptions (#3608)
* Add support for nested C++11 exceptions

* Remove wrong include

* Fix if directive

* Fix missing skipif

* Simplify code and try to work around MSVC bug

* Clarify comment

* Further simplify code

* Remove the last extra throw statement

* Qualify auto

* Fix typo

* Add missing return for consistency

* Fix clang-tidy complaint

* Fix python2 stub

* Make clang-tidy happy

* Fix compile error

* Fix python2 function signature

* Extract C++20 utility and backport

* Cleanup code a bit more

* Improve test case

* Consolidate code and fix signature

* Fix typo
2022-01-14 14:22:47 -05:00
Ralf W. Grosse-Kunstleve aa209cc90f Adding back test_class_sh, test_classh additions, building on PR #3590. 2022-01-11 17:48:59 -08:00
Ralf W. Grosse-Kunstleve ea0c1e77c8 Merge branch 'master' into sh_merge_master 2022-01-11 17:48:37 -08:00
Ralf W. Grosse-Kunstleve ea4cc147a2 Temporarily backing out all test_class_sh, test_classh additions. 2022-01-11 17:48:05 -08:00
Aaron Gokaslan f8d4aa47b6
Add clang-tidy readability checks for sus args (#3611) 2022-01-11 17:34:16 -08:00
Ivor Wanders 21911e126f
A way to register additional test targets and support .py only tests. (#3590)
* A way to register additional test targets.

* Support specifying tests with extension.

* Ensure TEST_OVERRIDE is backwards compatible.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Ensure regex is non greedy.

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2022-01-11 17:31:19 -08:00
Ralf W. Grosse-Kunstleve f588810871
Replacing ICC C++14 with C++17 (#3570)
* Replacing ICC C++14 with C++17

* ICPC: -diag-disable:conversion

Try to suppress the `-Werror-all` promotion in `#include <variant>`

* Trying `-DPYBIND11_WERROR=OFF`

* Trying `-Wno-conversion` (todo: make specific to C++17 if it works)

* Inserting -Wno-conversion only for C++17

Co-authored-by: Axel Huebl <axel.huebl@plasma.ninja>
2022-01-11 12:13:02 -08:00
Aaron Gokaslan ef070f7750
Add additional info to TypeError when C++->Python casting fails (#3605)
* Add additional info to TypeInfo when C++->Python casting fails

* Fix typo

* Address reviewer comments
2022-01-10 21:18:00 -05:00
Dustin Spicuzza 9e43db614f
fix: names of types held by smart holder should be the actual type (#3588)
Required for pybind11-stubgen to work properly
2022-01-03 15:46:13 -08:00
Ralf W. Grosse-Kunstleve 388c03b18c Merge branch 'master' into sh_merge_master_clean 2021-12-29 13:24:20 -08:00
Ralf W. Grosse-Kunstleve 1bbaeb3462
Adding dedicated test_const_name. (#3578)
* Adding dedicated test_const_name.

Also exercises pybind11::detail::_ backward compatibility.

See also: PR #3423

* Backing out tests involving int_to_str (requires C++17 or higher).

* Suppressing clang-tidy errors.

* Disabling test_const_name for MSVC 2015 due to bizarre failures.

* Stacking @pytest.mark.parametrize (thanks to @skylion007 for pointing out).
2021-12-29 12:54:25 -08:00
Henry Schreiner 39fbc7992b
fix: avoiding usage of _ if already defined (#3423)
* fix: avoid usage of _

* ci: test _ defined

* docs: include change in docs

* fix: add a test and comment

* refactor: const_str -> const_name
2021-12-21 14:24:21 -05:00
Ralf W. Grosse-Kunstleve d13e03af41 Merge branch 'master' into smart_holder 2021-12-03 10:07:57 -08:00
Jason Rhinelander b4939fcbfb
Expand std::string_view support to str, bytes, memoryview (#3521)
* Expand string_view support to str, bytes, memoryview

1. Allows constructing a str or bytes implicitly from a string_view;
   this is essentially a small shortcut allowing a caller to write
   `py::bytes{sv}` rather than `py::bytes{sv.data(), sv.size()}`.

2. Allows implicit conversion *to* string_view from py::bytes -- this
   saves a fair bit more as currently there is no simple way to get such
   a view of the bytes without copying it (or resorting to Python API
   calls).

   (This is not done for `str` because when the str contains unicode we
   have to allocate to a temporary and so there might not be some string
   data we can properly view without owning.)

3. Allows `memoryview::from_memory` to accept a string_view.  As with
   the other from_memory calls, it's entirely your responsibility to
   keep it alive.

This also required moving the string_view availability detection into
detail/common.h because this PR needs it in pytypes.h, which is higher
up the include chain than cast.h where it was being detected currently.

* Move string_view include to pytypes.h

* CI-testing a fix for the "ambiguous conversion" issue.

This change is known to fix the `tensorflow::tstring` issue reported under https://github.com/pybind/pybind11/pull/3521#issuecomment-985100965

TODO: Minimal reproducer for the `tensorflow::tstring` issue.

* Make clang-tidy happy (hopefully).

* Adding minimal reproducer for the `tensorflow::tstring` issue.

Error without the enable_if trick:

```
/usr/local/google/home/rwgk/forked/pybind11/tests/test_builtin_casters.cpp:169:16: error: ambiguous conversion for functional-style cast from 'TypeWithBothOperatorStringAndStringView' to 'py::bytes'
        return py::bytes(TypeWithBothOperatorStringAndStringView());
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/local/google/home/rwgk/forked/pybind11/include/pybind11/detail/../pytypes.h:1174:5: note: candidate constructor
    bytes(const std::string &s) : bytes(s.data(), s.size()) { }
    ^
/usr/local/google/home/rwgk/forked/pybind11/include/pybind11/detail/../pytypes.h:1191:5: note: candidate constructor
    bytes(std::string_view s) : bytes(s.data(), s.size()) { }
    ^
```

* Adding missing NOLINTNEXTLINE

* Also apply ambiguous conversion workaround to str()

Co-authored-by: Ralf W. Grosse-Kunstleve <rwgk@google.com>
2021-12-03 13:20:32 -04:00
Ralf W. Grosse-Kunstleve 98bdbba999 Merge branch 'master' into smart_holder 2021-11-22 01:35:01 -08:00
Ralf W. Grosse-Kunstleve 9281faf429
Fixing `stict` vs `strict` typo. (#3493) 2021-11-22 01:33:03 -08:00
Ralf W. Grosse-Kunstleve 7bbc5e3cdd Merge branch 'master' into smart_holder 2021-11-20 16:03:36 -08:00
Jason Rhinelander 673b4be3d7
Fix py::kw_only when used before the first arg of a method (#3488)
* Fix py::kw_only when used before the first arg of a method

The implicit space for the `self` argument isn't added until we hit the
first argument, but this wasn't being done for kw_only or pos_only, and
so a kw_only before the first argument would break.

This fixes it by properly checking whether we need to add the self arg.

(The pos_only issue here was extremely mild -- you didn't get the `/` in
the docstring, but AFAICT it has no other effect since there are no
meaningful arguments before it anyway).

* Style changes

- rename check_have_self_arg -> append_self_arg_if_needed

- move the argument name inline comments before the args instead of
  after
2021-11-20 16:01:57 -08:00
Ralf W. Grosse-Kunstleve e57afe23f7 Merge branch 'master' into smart_holder 2021-11-20 09:35:40 -08:00
Henry Schreiner 15f8d7c12e
fix(build): cleaner CMake printouts & IDE folders (#3479) 2021-11-18 10:01:24 -05:00
Henry Schreiner 72282f75a1
ci: support development releases of Python (#3419)
* ci: support development releases of Python

* fix: better PyPy support

* fix: patch over a few more pypy issues

* Try to patch

* Properly follow pep667

* Fix typo

* Whoops, 667 not in yet

* For testing

* More testing

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Try to backport

* Try to simplify fix

* Nail down the fix

* Try pypy workaround

* Typo

* one last typo

* Replacing 0x03110000 with 0x030B0000

* Add TODO. Drop PyPy

* Fix typo

* Revert catch upgrade

* fix: minor cleanup, try pypy again

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>
Co-authored-by: Ralf W. Grosse-Kunstleve <rwgk@google.com>
2021-11-17 09:44:19 -05:00
Ralf W. Grosse-Kunstleve 8a7643f471 Using `PYBIND11_SH_DEF` for `test_override_cache_helper` introduced by PR #3465. 2021-11-15 14:59:46 -08:00
Ralf W. Grosse-Kunstleve f4fab85d87 Merge branch 'master' into sh_merge_master 2021-11-15 14:43:08 -08:00
Trigve afdc09deda
[master] Wrong caching of overrides (#3465)
* override: Fix wrong caching of the overrides

There was a problem when the python type, which was stored in override
cache for C++ functions, was destroyed and  the record wasn't removed from the
override cache. Therefor, dangling pointer was stored there. Then when the
memory was reused and new type was allocated at the given address and the
method with the same name (as previously stored in the cache) was actually
overridden in python, it would wrongly find it in the override cache for C++
functions and therefor override from python wouldn't be called.
The fix is to erase the type from the override cache when the type is destroyed.

* test: Pass by const ref instead of by value (clang-tidy)

* test: Rename classes and move to different files

Rename the classes and files so they're no too generic. Also, better place to
test the stuff is in test_virtual_functions.cpp/.py as we're basically testing
the virtual functions/trampolines.

* Add TODO for erasure code

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2021-11-15 13:36:41 -05:00
Antony Lee b11ff912a6
fix(setup =_helpers): don't add -g0 CFLAGS sets -g (#3436)
On Unix, setuptools prepends $CFLAGS and $CPPFLAGS to the compiler flags
(they always come before extra_compile_args and anything else; see
distutils.sysconfig.customize_compiler).  In practice, the environment
variables are useful e.g. to quickly generate a debug build (e.g. by
setting CFLAGS=-g), but Pybind11Extension currently unconditionally
overwrites this with -g0.

Instead, check the environment variables and only insert -g0 if not
overridden by them.
2021-11-08 16:27:32 -05:00
Ralf W. Grosse-Kunstleve 58c7f076bc Merge branch 'master' into sh_merge_master 2021-11-07 16:26:55 -08:00