* 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
* 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>
* 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>
* docs: rework CI a bit, more modern skipping
* [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>
* fix: add missing std::forward calls
Two of the four cpp_function overloads are missing std::forward calls, which seems like a simple oversight.
* add test for https://github.com/pybind/pybind11/pull/3443
* add py tests
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* fix test
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
* Simply has_kw_only_args handling
This simplifies tracking the number of kw-only args by instead tracking
the number of positional arguments (which is really what we care about
everywhere this is used).
* Allow keyword-only arguments to follow py::args
This removes the constraint that py::args has to be last (or
second-last, with py::kwargs) and instead makes py::args imply
py::kw_only for any remaining arguments, allowing you to bind a function
that works the same way as a Python function such as:
def f(a, *args, b):
return a * b + sum(args)
f(10, 1, 2, 3, b=20) # == 206
With this change, you can bind such a function using:
m.def("f", [](int a, py::args args, int b) { /* ... */ },
"a"_a, "b"_a);
Or, to be more explicit about the keyword-only arguments:
m.def("g", [](int a, py::args args, int b) { /* ... */ },
"a"_a, py::kw_only{}, "b"_a);
(The only difference between the two is that the latter will fail at
binding time if the `kw_only{}` doesn't match the `py::args` position).
This doesn't affect backwards compatibility at all because, currently,
you can't have a py::args anywhere except the end/2nd-last.
* Take args/kwargs by const lvalue ref
Co-authored-by: Henry Schreiner <HenrySchreinerIII@gmail.com>
Co-authored-by: Henry Schreiner <HenrySchreinerIII@gmail.com>
* ci: support Python 3.11-dev
Also update 3.10 to final, better PyPy usage
* fix: use PyFrame_GetCode on Python 3.9+
* ci: some bitiness of pypy not supported on win
* chore: update CMake support to 3.22rc1 to quiet warning
* fix: use dev version of py to fix Py 3.11
* tests: print proper Eigen version
* ci: include pypy2, not sure why
* ci: avoid running on Python 3.11 for now
* ci: fix runs
* ci: simpler PyPy usage, drop unmaintained scipy + pypy index
* ci: only binary numpy, wait on pypy 3.8
* refactor: address review
* fix: the types for return_value_policy_override in optional_caster
`return_value_policy_override` was not being applied correctly in
`optional_caster` in two ways:
- The `is_lvalue_reference` condition referenced `T`, which was the
`optional<T>` type parameter from the class, when it should have used `T_`,
which was the parameter to the `cast` function. `T_` can potentially be a
reference type, but `T` will never be.
- The type parameter passed to `return_value_policy_override` should be
`T::value_type`, not `T`. This matches the way that the other STL container
type casters work.
The result of these issues was that a method/property definition which used a
`reference` or `reference_internal` return value policy would create a Python
value that's bound by reference to a temporary C++ object, resulting in
undefined behavior. For reasons that I was not able to figure out fully, it
seems like this causes problems when using old versions of `boost::optional`,
but not with recent versions of `boost::optional` or the `libstdc++`
implementation of `std::optional`. The issue (that the override to
`return_value_policy::move` is never being applied) is present for all
implementations, it just seems like that somehow doesn't result in problems for
the some implementation of `optional`. This change includes a regression type
with a custom optional-like type which was able to reproduce the issue.
Part of the issue with using the wrong types may have stemmed from the type
variables `T` and `T_` having very similar names. This also changes the type
variables in `optional_caster` to use slightly more descriptive names, which
also more closely follow the naming convention used by the other STL casters.
Fixes#3330
* Fix clang-tidy complaints
* Add missing NOLINT
* Apply a couple more fixes
* fix: support GCC 4.8
* tests: avoid warning about unknown compiler for compilers missing C++17
* Remove unneeded test module attribute
* Change test enum to have more unique int values
Co-authored-by: Aaron Gokaslan <skylion.aaron@gmail.com>
Co-authored-by: Henry Schreiner <HenrySchreinerIII@gmail.com>
* Adding MSVC C4127 suppression around Eigen includes.
* For MSVC 2015 only: also adding the C4127 suppression to test_eigen.cpp
* Copying original change from PR #3343, with extra line breaks to not run past 99 columns (our desired but currently not enforced limit).
* Add a test showing a flaw in make_key_iterator/make_value_iterator
If the iterator dereference operator returns a value rather than a
reference (and that pair also does not *contain* references),
make_key_iterator and make_value_iterator will return a reference to a
temporary, causing a segfault.
* Fix make_key_iterator/make_value_iterator for prvalue iterators
If an iterator returns a pair<T1, T2> rather than a reference to a pair
or a pair of references, make_key_iterator and make_value_iterator would
return a reference to a temporary, typically leading to a segfault. This
is because the value category of member access to a prvalue is an
xvalue, not a prvalue, so decltype produces an rvalue reference type.
Fix the type calculation to handle this case.
I also removed some decltype parentheses that weren't needed, either
because the expression isn't one of the special cases for decltype or
because decltype was only used for SFINAE. Hopefully that makes the code
a bit more readable.
Closes#3347
* Attempt a workaround for nvcc
* Add `.keys` and `.values` to bind_map
Both of these implement views (rather than just iterators), and `.items`
is also upgraded to a view. In practical terms, this allows a view to be
iterated multiple times and have its size taken, neither of which works
with an iterator.
The views implement `__len__`, `__iter__`, and the keys view implements
`__contains__`. Testing membership also works in item and value views
because Python falls back to iteration. This won't be optimal
for item values since it's linear rather than O(log n) or O(1), but I
didn't fancy trying to get all the corner cases to match Python
behaviour (tuple of wrong types, wrong length tuple, not a tuple etc).
Missing relative to Python dictionary views is `__reversed__` (only
added to Python in 3.8). Implementing that could break code that binds
custom map classes which don't provide `rbegin`/`rend` (at least without
doing clever things with SFINAE), so I've not tried.
The size increase on my system is 131072 bytes, which is rather large
(5%) but also suspiciously round (2^17) and makes me suspect some
quantisation effect.
* bind_map: support any object in __contains__
Add extra overload of `__contains__` (for both the map itself and
KeysView) which takes an arbitrary object and returns false.
* Take py::object by const reference in __contains__
To keep clang-tidy happy.
* Removing stray `py::` (detected via interactive testing in Google environment).
Co-authored-by: Ralf W. Grosse-Kunstleve <rwgk@google.com>
* Fix `pybind11::object::operator=` to be safe if `*this` is accessible from Python
* Add `custom_type_setup` attribute
This allows for custom modifications to the PyHeapTypeObject prior to
calling `PyType_Ready`. This may be used, for example, to define
`tp_traverse` and `tp_clear` functions.
* Add make_value_iterator (#3271)
* Add make_value_iterator
This is the counterpart to make_key_iterator, and will allow
implementing a `value` method in `bind_map` (although doing so is left
for a subsequent PR).
I made a few design changes to reduce copy-and-paste boilerplate.
Previously detail::iterator_state had a boolean template parameter to
indicate whether it was being used for make_iterator or
make_key_iterator. I replaced the boolean with a class that determines
how to dereference the iterator. This allows for a generic
implementation of `__next__`.
I also added the ValueType and Extra... parameters to the iterator_state
template args, because I think it was a bug that they were missing: if
make_iterator is called twice with different values of these, only the
first set has effect (because the state class is only registered once).
There is still a potential issue in that the *values* of the extra
arguments are latched on the first call, but since most policies are
empty classes this should be even less common.
* Add some remove_cv_t to appease clang-tidy
* Make iterator_access and friends take reference
For some reason I'd accidentally made it take a const value, which
caused some issues with third-party packages.
* Another attempt to remove remove_cv_t from iterators
Some of the return types were const (non-reference) types because of the
pecularities of decltype: `decltype((*it).first)` is the *declared* type
of the member of the pair, rather than the type of the expression. So if
the reference type of the iterator is `pair<const int, int> &`, then the
decltype is `const int`. Wrapping an extra set of parentheses to form
`decltype(((*it).first))` would instead give `const int &`.
This means that the existing make_key_iterator actually returns by value
from `__next__`, rather than by reference. Since for mapping types, keys
are always const, this probably hasn't been noticed, but it will affect
make_value_iterator if the Python code tries to mutate the returned
objects. I've changed things to use double parentheses so that
make_iterator, make_key_iterator and make_value_iterator should now all
return the reference type of the iterator. I'll still need to add a test
for that; for now I'm just checking whether I can keep Clang-Tidy happy.
* Add back some NOLINTNEXTLINE to appease Clang-Tidy
This is favoured over using remove_cv_t because in some cases a const
value return type is deliberate (particularly for Eigen).
* Add a unit test for iterator referencing
Ensure that make_iterator, make_key_iterator and make_value_iterator
return references to the container elements, rather than copies. The
test for make_key_iterator fails to compile on master, which gives me
confidence that this branch has fixed it.
* Make the iterator_access etc operator() const
I'm actually a little surprised it compiled at all given that the
operator() is called on a temporary, but I don't claim to fully
understand all the different value types in C++11.
* Attempt to work around compiler bugs
https://godbolt.org/ shows an example where ICC gets the wrong result
for a decltype used as the default for a template argument, and CI also
showed problems with PGI. This is a shot in the dark to see if it fixes
things.
* Make a test constructor explicit (Clang-Tidy)
* Fix unit test on GCC 4.8.5
It seems to require the arguments to the std::pair constructor to be
implicitly convertible to the types in the pair, rather than just
requiring is_constructible.
* Remove DOXYGEN_SHOULD_SKIP_THIS guards
Now that a complex decltype expression has been replaced by a simpler
nested type, I'm hoping Doxygen will be able to build it without issues.
* Add comment to explain iterator_state template params
* fix: regression in #3271
Co-authored-by: Bruce Merry <1963944+bmerry@users.noreply.github.com>
* Adding nullptr slices
Using example from #1095
Some fixes from @wjakob's review
Stop clang-tidy from complaining
New proposal for py::slice constructor
Eric's suggested changes: simplify testing; shift def's
* chore: drop MSVC pragma (hopefully unneeded)
* Apply suggestions from code review
* Add make_value_iterator
This is the counterpart to make_key_iterator, and will allow
implementing a `value` method in `bind_map` (although doing so is left
for a subsequent PR).
I made a few design changes to reduce copy-and-paste boilerplate.
Previously detail::iterator_state had a boolean template parameter to
indicate whether it was being used for make_iterator or
make_key_iterator. I replaced the boolean with a class that determines
how to dereference the iterator. This allows for a generic
implementation of `__next__`.
I also added the ValueType and Extra... parameters to the iterator_state
template args, because I think it was a bug that they were missing: if
make_iterator is called twice with different values of these, only the
first set has effect (because the state class is only registered once).
There is still a potential issue in that the *values* of the extra
arguments are latched on the first call, but since most policies are
empty classes this should be even less common.
* Add some remove_cv_t to appease clang-tidy
* Make iterator_access and friends take reference
For some reason I'd accidentally made it take a const value, which
caused some issues with third-party packages.
* Another attempt to remove remove_cv_t from iterators
Some of the return types were const (non-reference) types because of the
pecularities of decltype: `decltype((*it).first)` is the *declared* type
of the member of the pair, rather than the type of the expression. So if
the reference type of the iterator is `pair<const int, int> &`, then the
decltype is `const int`. Wrapping an extra set of parentheses to form
`decltype(((*it).first))` would instead give `const int &`.
This means that the existing make_key_iterator actually returns by value
from `__next__`, rather than by reference. Since for mapping types, keys
are always const, this probably hasn't been noticed, but it will affect
make_value_iterator if the Python code tries to mutate the returned
objects. I've changed things to use double parentheses so that
make_iterator, make_key_iterator and make_value_iterator should now all
return the reference type of the iterator. I'll still need to add a test
for that; for now I'm just checking whether I can keep Clang-Tidy happy.
* Add back some NOLINTNEXTLINE to appease Clang-Tidy
This is favoured over using remove_cv_t because in some cases a const
value return type is deliberate (particularly for Eigen).
* Add a unit test for iterator referencing
Ensure that make_iterator, make_key_iterator and make_value_iterator
return references to the container elements, rather than copies. The
test for make_key_iterator fails to compile on master, which gives me
confidence that this branch has fixed it.
* Make the iterator_access etc operator() const
I'm actually a little surprised it compiled at all given that the
operator() is called on a temporary, but I don't claim to fully
understand all the different value types in C++11.
* Attempt to work around compiler bugs
https://godbolt.org/ shows an example where ICC gets the wrong result
for a decltype used as the default for a template argument, and CI also
showed problems with PGI. This is a shot in the dark to see if it fixes
things.
* Make a test constructor explicit (Clang-Tidy)
* Fix unit test on GCC 4.8.5
It seems to require the arguments to the std::pair constructor to be
implicitly convertible to the types in the pair, rather than just
requiring is_constructible.
* Remove DOXYGEN_SHOULD_SKIP_THIS guards
Now that a complex decltype expression has been replaced by a simpler
nested type, I'm hoping Doxygen will be able to build it without issues.
* Add comment to explain iterator_state template params
* Enable defining custom __new__
* See if xfail needed
* Qualify auto self
* Unconditionally defining PYBIND11_DISABLE_NEW_STYLE_INIT_WARNING. Returning pointer from "__init__" instead of reference.
* Use new style __init__
* Simplify __new__ creation
* Reviewer suggestions
* Match indentation
Co-authored-by: Ralf W. Grosse-Kunstleve <rwgk@google.com>
* Eliminate duplicate TLS keys for loader_life_support stack
This revises the existing fix for
https://github.com/pybind/pybind11/issues/2765 in
https://github.com/pybind/pybind11/pull/3237 to reduce the amount of
TLS storage used.
The shared TLS key is stored in two different ways, depending on
`PYBIND11_INTERNALS_VERSION`. If `PYBIND11_INTERNALS_VERSION ==
4` (as is currently set), the TLS key is stored in the
`internal::shared_data` map to avoid breaking ABI compatibility. If
`PYBIND11_INTERNALS_VERSION > 4`, the TLS key is stored directly in
the `internals` struct.
* Fix test_pytypes.py::test_issue2361 failure on PyPy3.7
* Add github actions tests for unstable ABI
* Restoring `const` removed from pytypes.h in PR #3254, adding tests reflective of user code that breaks when those `const` are removed.
* clang-tidy NOLINTs (and one collateral fix).
* Inserting PYBIND11_CONST_FOR_STRICT_PLATFORMS
* Trying `defined(__APPLE__)`
* Trying again: `auto it` for strict platforms.
* Adding NOLINTNEXTLINE(bugprone-macro-parentheses), expanding comments.
* Labeling all changes with `PR #3263`, for easy reference, and to make it easy to undo these changes if we decide to do so in the future.
* Fix thread safety for pybind11 loader_life_support
Fixes issue: https://github.com/pybind/pybind11/issues/2765
This converts the vector of PyObjects to either a single void* or
a per-thread void* depending on the WITH_THREAD define.
The new field is used by each thread to construct a stack
of loader_life_support frames that can extend the life of python
objects.
The pointer is updated when the loader_life_support object is allocated
(which happens before a call) as well as on release.
Each loader_life_support maintains a set of PyObject references
that need to be lifetime extended; this is done by storing them
in a c++ std::unordered_set and clearing the references when the
method completes.
* Also update the internals version as the internal struct is no longer compatible
* Add test demonstrating threading works correctly.
It may be appropriate to run this under msan/tsan/etc.
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Update test to use lifetime-extended references rather than
std::string_view, as that's a C++ 17 feature.
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Make loader_life_support members private
* Update version to dev2
* Update test to use python threading rather than concurrent.futures
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Remove unnecessary env in test
* Remove unnecessary pytest in test
* Use native C++ thread_local in place of python per-thread data structures to retain compatability
* clang-format test_thread.cpp
* Add a note about debugging the py::cast() error
* thread_test.py now propagates exceptions on join() calls.
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* remove unused sys / merge
* Update include order in test_thread.cpp
* Remove spurious whitespace
* Update comment / whitespace.
* Address review comments
* lint cleanup
* Fix test IntStruct constructor.
* Add explicit to constructor
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Aaron Gokaslan <skylion.aaron@gmail.com>
* Set __file__ constant when using eval_file
* Use const ref
* Use a move instead
* Revert
* Improve test
* Guard test with Python version
* Fix tests
* Dont support Python2 API
* Drop Python2 eval __file__ support
* Hack
* Semisupport Python2
* Take2
* Remove Python2 support
* fix: memory leak in cpp_function (#3228)
* add a test case to check objects are deconstructed in cpp_function
* update the test case about cpp_function
* fix the test case about cpp_function: remove "noexcept"
* Actually calling func. CHECK(stat.alive() == 2); Manually verified that the new tests fails without the change in pybind11.h
* Moving new test to test_callbacks.cpp,py, with small enhancements.
* Removing new test from test_interpreter.cpp (after it was moved to test_callbacks.cpp,py). This restores test_interpreter.cpp to the current state on master.
* Using py::detail::silence_unused_warnings(py_func); to make the intent clear.
Co-authored-by: Ralf W. Grosse-Kunstleve <rwgk@google.com>
* Trivial change to avoid (ssize_t) cast.
* Demo for safe_ssize_t idea.
* Removing safe_ssize_t.cpp (proof-of-concept code) to not upset the GHA Format workflow.
* Completing changes in pytypes.h
* New ssize_t_cast (better replacement for safe_ssize_t).
* clang-format-diff (no manual changes).
* bytes_ssize_t -Wnarrowing reproducer (see PR #2692).
* Backing out tuple(), list() ssize_t support, for compatibility with older compilers (to resolve link failures).
* Bug fix: missing `py::` for `py::ssize_t`
* Restoring tuple(), list() ssize_t support, but passing `size` by value, for compatibility with older compilers (to resolve link failures).
* Full test coverage of all functions with modified signatures.
* Use equivalent_integer for enum's Scalar decision
* Add test for char underlying enum
* Support translating bool type in enum's Scalar
* Add test for bool underlying enum
* Fix comment in test
* Switch from `PYBIND11_CPP20` macro to `PYBIND11_HAS_U8STRING`
* Refine tests
Co-authored-by: Aaron Gokaslan <skylion.aaron@gmail.com>
* Call PySys_SetArgv when initializing interpreter.
* Document argc/argv parameters in initialize_interpreter.
* Remove manual memory management from set_interpreter_argv in favor of smart pointers.
* Use size_t for indexers in set_interpreter_argv.
* Minimize macros for flow control in set_interpreter_argv.
* Fix 'unused variable' warning on Py2
* whitespace
* Define wide_char_arg_deleter outside set_interpreter_argv.
* Do sys.path workaround in C++ rather than eval.
* Factor out wchar conversion to a separate function.
* Restore widened_argv variable declaration.
* Fix undeclared widened_arg variable on some paths.
* Use delete[] to match new wchar_t[].
* Fix compiler errors
* Use PY_VERSION_HEX for a cleaner CVE-2008-5983 mode check.
* Fix typo
* Use explicit type for deleter so delete[] works cross-compiler.
* Always use PySys_SetArgvEx because pybind11 doesn't support pythons that don't include it.
* Remove pointless ternary operator.
* Use unique_ptr.reset instead of a second initialization.
* Rename add_program_dir_to_path parameter to clarify intent.
* Add defined() check before evaluating HAVE_BROKEN_MBSTOWCS.
* Apply clang-tidy fixes
* Pre-commit
* refactor: use const for set_interpreter_argv
* Try to fix const issue and allocate vector properly
* fix: copy strings on Python 2
* Applying clang-format-diff relative to master.
The only manual change is an added empty line between pybind11 and system `#include`s.
```
git diff -U0 --no-color master | python3 $HOME/clone/llvm-project/clang/tools/clang-format/clang-format-diff.py -p1 -style=file -i
```
Co-authored-by: Boris Staletic <boris.staletic@gmail.com>
Co-authored-by: Aaron Gokaslan <skylion.aaron@gmail.com>
Co-authored-by: Henry Schreiner <henryschreineriii@gmail.com>
Co-authored-by: Ralf W. Grosse-Kunstleve <rwgk@google.com>
* Add py::raise_from to enable chaining exceptions on Python 3.3+
* Use 'raise from' in initialization
* Documenting the exact base version of _PyErr_FormatVFromCause, adding back `assert`s.
Co-authored-by: Dustin Spicuzza <dustin@virtualroadside.com>
* Removing all MSVC C4127 warning suppression pragmas.
* Removing MSVC /WX (WERROR). To get a full list of all warnings.
* Inserting PYBIND11_SILENCE_MSVC_C4127. Changing one runtime if to #if.
* Changing PYBIND11_SILENCE_MSVC_C4127 macro to use absolute namespace (for use outside pybind11 include directory).
* Restoring MSVC /WX (WERROR).
* Removing globally-scoped suppression for clang -Wunsequenced. Based on an experiment under PR #3202 it is obsolete and can simply be removed.
* Removing all pragma from eigen.h
* Removing -Werror or equivalent from tests/CMakeLists.txt
* Restoring tests/CMakeLists.txt from master.
* Adding 4 PYBIND11_SILENCE_MSVC_C4127.
* Compatibility with -Wconversion, -Wdeprecated
* Introducing PYBIND11_COMPATIBILITY_WDEPRECATED_COPY
* Systematically using --verbose for compilations where possible (cmake 3.14 or newer).
Also changing all `cmake -t` to `--target`, `-v` to `--verbose`, `check` to `pytest`, for consistency (to make it easier to pin-point all commands of a certain type).
Also removing one `-j 2` for `pytest` in hopes of reducing flakes due to races in test_iostream and in prints from destructors.
* Commenting out pragmas as an experiment to reproduce previous observation.
* Removing all (newly added, but already commented-out) pragma code, adding HINT use -isystem (as cmake does).
* Restoring ci.yml from master. Those changes are better handled separately. BTW: in the last CI run there was still a test_iostream flake, even without the -j 2 for running the tests (verfied by inspecting the log).
* Fix errant const methods
* Remove NOLINT since clang-tidy is pretty conservative
* Missed one
* Fix a few more errors
* Add reviewer suggested comments
* Run clang-format
The only manual intervention was to remove the merge conflict markers in pybind11.h.
TODO in separate commit: complete removal of the obsolete detail/pragma_warning_block.h.
* Removing last remnants of pragma block at the top of pybind11.h, defaulting CUDA, GCC7, GCC8 to PYBIND11_NOINLINE_DISABLED, with the option to define PYBIND11_NOINLINE_FORCED.
* Unique SOSIZE prefix to make it easier to extract the sosizes from the GitHub logs.
* Commenting out PYBIND11_WERROR block, for noinline testing.
* Undoing accidental change.
* `#define PYBIND11_NOINLINE_FORCED`
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* `#define PYBIND11_NOINLINE_DISABLED`
* Going back to default (removing `#define PYBIND11_NOINLINE_DISABLED`).
* `#define PYBIND11_NOINLINE_FORCED`
* Undoing all changes releated to measuring sosizes.
* Rollback of PR #3030 (Working around Centos 8 failure).
* Disabling -Werror for GNU (experiment).
* Commenting out the entire `if(PYBIND11_WERROR)` again (although that is not expected to make a difference, but who knows what I am overlooking).
* Adding `-DCMAKE_BUILD_TYPE=Release`
* Undoing change to tests/CMakeLists.txt (uncommenting `if(PYBIND11_WERROR)` block).
* post `git rebase master -X theirs` fixups.
* Adding measurements to comment for `PYBIND11_NOINLINE_FORCED`.
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
* Removing pragma for GCC -Wattributes, fixing forward declarations.
* Introducing PYBIND11_NOINLINE_FWD to deal with CUDA, GCC7, GCC8.
* Updating PYBIND11_NOINLINE_DCL in Doxyfile.
* Trying noinline, noinline for {CUDA, GCC7, GCC8}
* Trying noinline, inline for {CUDA, GCC7, GCC8}
* Adding GCC -Wattributes `pragma` in 3 header files.
* Introducing PYBIND11_NOINLINE_GCC_PRAGMA_ATTRIBUTES_NEEDED, used in 9 header files.
* Removing ICC pragma 2196, to see if it is still needed.
* Trying noinline, noinline for ICC
* Trying noinline, inline for ICC
* Restoring ICC pragma 2196, introducing PYBIND11_NOINLINE_FORCED, defined for testing.
* Removing code accidentally left in (was for experimentation only).
* Removing one-time-test define.
* Removing PYBIND11_NOINLINE_FWD macro (after learning that it makes no sense).
* Testing with PYBIND11_NOINLINE_DISABLED. Minor non-functional enhancements.
* Removing #define PYBIND11_NOINLINE_DISABLED (test was successful).
* Removing PYBIND11_NOINLINE_FORCED and enhancing comments for PYBIND11_NOINLINE.
* WIP stripping back
* Making -Wattributes pragma in pybind11 specific to GCC7, GCC8, CUDA.
* Cleanup triggered by work on pragma for GCC -Wunused-but-set-parameter.
* Backing out changes to eigen.h (to be worked on later).
* Adding PYBIND11_WORKAROUND_INCORRECT_GCC_UNUSED_BUT_SET_PARAMETER in type_caster_base.h (apparently needed only for older GCCs).
* Apparently older compilers need a simpler overload for silence_unused_warnings().
* clang C++11 compatibility: removing constexpr
* Special case for MSVC 2017: `constexpr void` return
* Trying again without the silence_unused_warnings(const int *) overload.
* Separate macros for ALL_GCC, OLD_GCC_UNUSED_BUT_SET_PARAMETER
* Changing to __GNUC__ <= 2 (turning off)
* Refined condition for PYBIND11_WORKAROUND_INCORRECT_OLD_GCC_UNUSED_BUT_SET_PARAMETER.
* Quick experiment trying out suggestion by @henryiii
* Introducing macro: PYBIND11_INT_ARRAY_WORKING_AROUND_MSVC_CLANG_ISSUES
* Trying henryiii@ (void) expander idea.
* fix: apply simpler expression with fewer workarounds
* Purging new-but-already-obsoleted macro, made possible by @henryiii's commit.
* Renaming `ALL_GCC` macro back to just `GCC` (because there is no `OLD` anymore, luckily).
* [actions skip] Adding "All GCC versions" to comment, to be clear about it.
Co-authored-by: Henry Schreiner <henryschreineriii@gmail.com>
* Removing pragma for 4127 (to see what is still broken with the latest code).
* Using new constexpr_bool() to suppress warning C4127.
* One missed case, Python 2 only.
* PYBIND11_SILENCE_MSVC_C4127 (more similar to the approach for C4100).
* Moving pragma for C4505 from pybind11.h to existing list in detail/common.h.
* Removing 4 existing suppressions to 1. see what is still needed and 2. capture the MSVC messages.
* It turns out none of the 4 pragmas are needed anymore.
* mingw64 platform string is like mingw_xxx not "mingw"
See https://github.com/msys2/MINGW-packages/blob/master/mingw-w64-python/0099-Change-the-get_platform-method-in-sysconfig-and-dist.patch
* Mingw: Do not dllexport exceptions
This is a fix for errors like:
D:/a/pybind11/pybind11/include/pybind11/detail/common.h:735:23: error: 'dllexport' implies default visibility, but 'class pybind11::builtin_exception' has already been declared with a different visibility
735 | class PYBIND11_EXPORT builtin_exception : public std::runtime_error {
| ^~~~~~~~~~~~~~~~~
* GHA: Test Mingw64 build
* fix: avoid thin binaries on mingw
* fix: drop lto on MinGW
* Mingw64: disable PYBIND11_DEPRECATED
It trigger many warnings for unknown reasons
Co-authored-by: Henry Schreiner <henryschreineriii@gmail.com>
* Moving pragma for ignoring -Wnoexcept-type to the one location where it is needed.
* Trying a second location.
* The previous commit worked (GitHub Actions green), but see the added comment about the dicy nature of -Wnoexcept-type ("if and only if").
* Applying reviewer suggestion.
* Removing pragma for 4100 (to see what is still broken with the latest code).
* Adding --keep-going
* Revert "Adding --keep-going"
This reverts commit 1c844c6ffd07a6111b644811e7e3b0a50b9d44bb.
* Introducing PYBIND11_WORKAROUND_INCORRECT_MSVC_C4100.
* _MSC_VER <= 1916
* Replacing simple variadic function with variadic template (attempt to resolve MSVC 2017 failures).
* Preserving existing comment (moved from pybind11.h to detail/common.h).
* Adding blank lines for readability.
* Fixing `pragma warning pop` for `__INTEL_COMPILER`.
* Adding push/pop to 3 tests. Removing #878 from top of pybind11.h (it was/is only needed for 1 test).
* Trying again after CI failure, moving the push to the top of 2 tests.
* Trying more after CI failure, adding push/pop to pybind11_tests.h, constructor_stats.h.
* Moving ICC #2196 suppression to CMakeLists.txt
* Fixing condition for `pragma GCC diagnostic push` in pybind11.h
* Moving `pragma warning disable 2196` to common.h
* Revising #ifdef to be more conservative.
* Undoing insertion of notes that will hopefully soon be completely obsolete anyway.