Ralf W. Grosse-Kunstleve
f6e543b15e
Adding a default virtual destructor to Animal type in test_tagbased_polymorphic.cpp.
...
With this change, and cast.h as-is in master, test_tagbased_polymorphic.cpp fails to compile with the error message below.
With the cast.h change in pull/2016, building and testing succeeds.
cd pybind11/build/tests && /usr/bin/c++ -DPYBIND11_TEST_BOOST -DPYBIND11_TEST_EIGEN -Dpybind11_tests_EXPORTS -Ipybind11/include -I/usr/include/python3.7m -isystem /usr/include/eigen3 -Os -DNDEBUG -fPIC -fvisibility=hidden -std=c++2a -flto -fno-fat-lto-objects -Wall -Wextra -Wconversion -Wcast-qual -Wdeprecated -o CMakeFiles/pybind11_tests.dir/test_tagbased_polymorphic.cpp.o -c pybind11/tests/test_tagbased_polymorphic.cpp
In file included from pybind11/include/pybind11/attr.h:13,
from pybind11/include/pybind11/pybind11.h:44,
from pybind11/tests/pybind11_tests.h:2,
from pybind11/tests/test_tagbased_polymorphic.cpp:10:
pybind11/include/pybind11/cast.h: In instantiation of ‘static std::pair<const void*, const pybind11::detail::type_info*> pybind11::detail::type_caster_base<type>::src_and_type(const itype*) [with type = Animal; pybind11::detail::type_caster_base<type>::itype = Animal]’:
pybind11/include/pybind11/cast.h:906:31: required from ‘static pybind11::handle pybind11::detail::type_caster_base<type>::cast_holder(const itype*, const void*) [with type = Animal; pybind11::detail::type_caster_base<type>::itype = Animal]’
pybind11/include/pybind11/cast.h:1566:51: required from ‘static pybind11::handle pybind11::detail::move_only_holder_caster<type, holder_type>::cast(holder_type&&, pybind11::return_value_policy, pybind11::handle) [with type = Animal; holder_type = std::unique_ptr<Animal>]’
pybind11/include/pybind11/stl.h:175:69: required from ‘static pybind11::handle pybind11::detail::list_caster<Type, Value>::cast(T&&, pybind11::return_value_policy, pybind11::handle) [with T = std::vector<std::unique_ptr<Animal> >; Type = std::vector<std::unique_ptr<Animal> >; Value = std::unique_ptr<Animal>]’
pybind11/include/pybind11/pybind11.h:159:43: required from ‘void pybind11::cpp_function::initialize(Func&&, Return (*)(Args ...), const Extra& ...) [with Func = std::vector<std::unique_ptr<Animal> > (*&)(); Return = std::vector<std::unique_ptr<Animal> >; Args = {}; Extra = {pybind11::name, pybind11::scope, pybind11::sibling}]’
pybind11/include/pybind11/pybind11.h:64:9: required from ‘pybind11::cpp_function::cpp_function(Return (*)(Args ...), const Extra& ...) [with Return = std::vector<std::unique_ptr<Animal> >; Args = {}; Extra = {pybind11::name, pybind11::scope, pybind11::sibling}]’
pybind11/include/pybind11/pybind11.h:819:22: required from ‘pybind11::module& pybind11::module::def(const char*, Func&&, const Extra& ...) [with Func = std::vector<std::unique_ptr<Animal> > (*)(); Extra = {}]’
pybind11/tests/test_tagbased_polymorphic.cpp:141:36: required from here
pybind11/include/pybind11/cast.h:880:61: error: ambiguous template instantiation for ‘struct pybind11::polymorphic_type_hook<Animal, void>’
const void *vsrc = polymorphic_type_hook<itype>::get(src, instance_type);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~
pybind11/include/pybind11/cast.h:844:8: note: candidates are: ‘template<class itype> struct pybind11::polymorphic_type_hook<itype, typename std::enable_if<std::is_polymorphic<_Tp>::value, void>::type> [with itype = Animal]’
struct polymorphic_type_hook<itype, detail::enable_if_t<std::is_polymorphic<itype>::value>>
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
pybind11/tests/test_tagbased_polymorphic.cpp:115:12: note: ‘template<class itype> struct pybind11::polymorphic_type_hook<itype, typename std::enable_if<std::is_base_of<Animal, itype>::value, void>::type> [with itype = Animal]’
struct polymorphic_type_hook<itype, detail::enable_if_t<std::is_base_of<Animal, itype>::value>>
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from pybind11/include/pybind11/attr.h:13,
from pybind11/include/pybind11/pybind11.h:44,
from pybind11/tests/pybind11_tests.h:2,
from pybind11/tests/test_tagbased_polymorphic.cpp:10:
pybind11/include/pybind11/cast.h:880:61: error: incomplete type ‘pybind11::polymorphic_type_hook<Animal, void>’ used in nested name specifier
const void *vsrc = polymorphic_type_hook<itype>::get(src, instance_type);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~
2020-04-14 17:48:43 +02:00
Ralf W. Grosse-Kunstleve
4697149d19
Allows users to specialize polymorphic_type_hook with std::enable_if.
...
Currently user specializations of the form
template <typename itype> struct polymorphic_type_hook<itype, std::enable_if_t<...>> { ... };
will fail if itype is also polymorphic, because the existing specialization will also
be enabled, which leads to 2 equally viable candidates. With this change, user provided
specializations have higher priority than the built in specialization for polymorphic types.
2020-04-14 17:48:43 +02:00
Wenzel Jakob
0234871649
begin working on next version
2020-03-31 13:09:41 +02:00
Wenzel Jakob
3b1dbebabc
v2.5.0 release
2020-03-31 13:00:39 +02:00
Wenzel Jakob
bb9c91cce8
pybind11Tools.cmake: search for Python 3.9
2020-03-04 16:17:20 +01:00
Baljak
4f72ef846f
Fix the use of MSVC in an MSYS environment ( #2087 )
2020-01-22 11:49:56 +01:00
fwjavox
e97c735fc4
stl_bind: add binding for std::vector::clear ( #2074 )
2020-01-17 01:16:56 +01:00
Baljak
07e2259322
Fix compilation with MinGW only ( #2053 )
2020-01-05 15:49:59 +01:00
Robert Haschke
370a2ae2b3
Declare call_impl() as && ( #2057 )
2020-01-05 15:49:24 +01:00
Wenzel Jakob
bf2b031449
Handle cases where binding code immediately throws py::error_already_set
...
When binding code immediately throws an exception of type
py::error_already_set (e.g. via py::module::import that fails), the
catch block sets an import error as expected. Unfortunately, following
this, the deconstructor of py::error_already_set decides to call
py::detail::get_internals() and set up various internal data structures
of pybind11, which fails given that the error flag is active. The call
stack of this looks as follows:
Py_init_mymodule() -> __cxa_decrement_exception_refcount ->
error_already_set::~error_already_set() ->
gil_scoped_acquire::gil_scoped_acquire() -> detail::get_internals() ->
... -> pybind11::detail::simple_collector() -> uh oh..
The solution is simple: we call detail::get_internals() once before
running any binding code to make sure that the internal data structures
are ready.
2020-01-02 22:18:03 +01:00
Wenzel Jakob
4c206e8c79
bindings for import_error exception
2020-01-02 22:17:20 +01:00
Wenzel Jakob
2fda9d5dd8
Travis CI fix (MacOS, Py3)
2019-12-31 01:26:40 +01:00
Wenzel Jakob
f9f3bd711f
Use C++17 fold expressions when casting tuples and argument lists ( #2043 )
...
This commit introduces the use of C++17-style fold expressions when
casting tuples & the argument lists of functions.
This change can improve performance of the resulting bindings: because
fold expressions have short-circuiting semantics, pybind11 e.g. won't
try to cast the second argument of a function if the first one failed.
This is particularly effective when working with functions that have
many overloads with long argument lists.
2019-12-30 01:26:32 +01:00
Vemund Handeland
6e39b765b2
Add C++20 char8_t/u8string support ( #2026 )
...
* Fix test build in C++20
* Add C++20 char8_t/u8string support
2019-12-19 12:16:24 +01:00
JGamache-autodesk
37d04abdee
Fixes #1295 : Handle debug interpreter ( #2025 )
...
If a debug interpreter is detected, we allow linking with
pythonXX_d.lib under windows.
2019-12-19 12:15:42 +01:00
Wenzel Jakob
b4e5d582cb
undo #define copysign in pyconfig.h
2019-12-13 11:11:33 +01:00
Boris Staletic
1376eb0e51
Free tstate on python 3.7+ on finalize_interpreter ( #2020 )
2019-12-12 15:55:54 +01:00
Wenzel Jakob
fb910ae92b
Revert "Fix a memory leak when creating Python3 modules. ( #2019 )"
...
This reverts commit 819802da99
.
2019-12-11 21:26:46 +01:00
Nils Berg
819802da99
Fix a memory leak when creating Python3 modules. ( #2019 )
2019-12-11 16:01:45 +01:00
Boris Staletic
dc9006db4f
Use newer macOS image for python3 testing
2019-12-11 13:17:03 +01:00
Boris Staletic
fe2a06e339
Pin breathe to 4.13.1
2019-12-11 13:17:03 +01:00
Isuru Fernando
3735249122
Install headers using both headers and package_data ( #1995 )
2019-11-28 15:59:23 +08:00
Wenzel Jakob
a60648223d
Revert "numpy.h: minor preprocessor fix suggested by @chaekwan"
...
This reverts commit 61e4f11823
.
2019-11-28 08:07:32 +01:00
Wenzel Jakob
61e4f11823
numpy.h: minor preprocessor fix suggested by @chaekwan
2019-11-28 07:42:34 +01:00
Eric Cousineau
baf69345f6
Minor modifications to interrupt handling FAQ ( #2007 )
2019-11-25 22:14:06 +08:00
Charles Brossollet
0f1d3bfee2
Add FAQ entry for dealing with long functions interruption ( #2000 )
...
* Add FAQ entry, with code example, for dealing with long functions interruption
2019-11-25 17:59:53 +08:00
Sebastian Koslowski
dc65d66171
support for readonly buffers ( #863 ) ( #1466 )
2019-11-24 08:33:05 +01:00
Francesco Biscani
bd24155b8b
Aligned allocation fix for clang-cl ( #1988 )
2019-11-16 01:18:24 +01:00
Francesco Biscani
deb3cb238a
Add exception translation for std::overflow_error. ( #1977 )
2019-11-14 08:56:58 +01:00
Yannick Jadoul
55ff464233
Fixing SystemError when nb_bool/nb_nonzero sets a Python exception in type_caster<bool>::load ( #1976 )
2019-11-14 08:56:22 +01:00
Erick Matsen
b32b762c60
Fixing minor typo in basics.rst ( #1984 )
2019-11-14 08:54:46 +01:00
Matthew Dawkins
6f11347a30
Prevent cmake error when prefix empty ( #1986 )
2019-11-14 08:53:06 +01:00
Axel Huebl
a6355b00f8
CMake: Add Python 3.8 to pybind11Tools ( #1974 )
...
Add Python 3.8 to considered versions in CMake for additional
hints.
https://cmake.org/cmake/help/v3.2/module/FindPythonLibs.html
2019-10-31 12:40:15 +01:00
Sebastian Gsänger
a83d69e78f
test pair-copyability on C++17 upwards ( #1886 )
...
* test pair-copyability on C++17 upwards
The stdlib falsely detects containers like M=std::map<T, U>
as copyable, even when one of T and U is not copyable.
Therefore we cannot rely on the stdlib dismissing std::pair<T, M>
by itself, even on C++17.
* fix is_copy_assignable
bind_map used std::is_copy_assignable which suffers from the same problems
as std::is_copy_constructible, therefore the same fix has been applied.
* created tests for copyability
2019-10-31 12:38:24 +01:00
Hans Dembinski
bdf6a5e870
Report type names in return value policy-related cast exceptions ( #1965 )
2019-10-23 13:19:58 +02:00
Hans Dembinski
c27a6e1378
make builds with python tests and cpp tests fail if either one fails ( #1967 )
2019-10-22 17:19:15 +02:00
Jeremy Nimmer
759221f5c5
Obey __cpp_sized_deallocation and __cpp_aligned_new
...
Don't assume that just because the language version is C++17 that the
standard library offers all C++17 features, too. When using clang-6.0
and --std=c++17 on Ubuntu 18.04 with libstdc++, __cpp_sized_deallocation
is false.
2019-10-22 11:02:11 +02:00
Riccardo Bertossa
6c29cbf88d
misleading comment corrected (strides in buffer_info is bytes and not number of entries) ( #1958 )
2019-10-18 17:55:17 +02:00
nicolov
de5a29c0d4
Fix build with -Wmissing-prototypes ( #1954 )
...
When building with `-Werror,-Wmissing-prototypes`, `clang` complains about missing prototypes for functions defined through macro expansions. This PR adds the missing prototypes.
```
error: no previous prototype for function 'pybind11_init_impl_embedded' [
-Werror,-Wmissing-prototypes]
PYBIND11_EMBEDDED_MODULE(embedded, mod) {
^
external/pybind11/include/pybind11/embed.h:61:5: note: expanded from macro 'PYBIND11_EMBEDDED_MODULE'
PYBIND11_EMBEDDED_MODULE_IMPL(name) \
^
external/pybind11/include/pybind11/embed.h:26:23: note: expanded from macro 'PYBIND11_EMBEDDED_MODULE_IMPL'
extern "C" void pybind11_init_impl_##name() { \
^
<scratch space>:380:1: note: expanded from here
pybind11_init_impl_embedded
^
1 error generated.
```
2019-10-17 10:43:33 +02:00
Wenzel Jakob
dfde1554ea
begin working on next version
2019-10-15 01:58:43 +02:00
Wenzel Jakob
80d452484c
v2.4.3 release
2019-10-15 01:57:24 +02:00
Sergei Izmailov
6cb584e9de
Adapt to python3.8 C API change ( #1950 )
...
* Adapt to python3.8 C API change
Do `Py_DECREF(type)` on all python objects on deallocation
fix #1946
* Add bare python3.8 build to CI matrix
While numpy/scipy wheels are available, run python3.8 test without them
2019-10-08 18:25:09 +02:00
Boris Dalstein
96be2c154f
Fix version mismatch typos in .travis.yml ( #1948 )
2019-10-06 23:23:10 +02:00
Wenzel Jakob
34c2281e31
begin working on next version
2019-09-21 20:23:01 +02:00
Wenzel Jakob
2abd7e1eb4
updated release.rst to remove parts that are now automated
2019-09-21 20:22:33 +02:00
Wenzel Jakob
7ec2ddfc95
v2.4.2 release
2019-09-21 20:20:26 +02:00
Wenzel Jakob
7f5dad7d5f
Remove usage of C++14 constructs ( fixes #1929 )
2019-09-21 19:03:14 +02:00
Wenzel Jakob
f3109d8419
future-proof Python version check from commit 31680e6
(@lgritz)
2019-09-21 18:09:35 +02:00
Wenzel Jakob
82cf793588
begin working on next version
2019-09-20 11:12:22 +02:00
Wenzel Jakob
e44fcc3c15
v2.4.1 release
2019-09-20 11:10:49 +02:00