Commit Graph

968 Commits

Author SHA1 Message Date
peter
03f9e4a8ec Fix compilation with clang-cl 2020-04-26 09:47:34 +02:00
Dustin Spicuzza
0dfffcf257 Add is_final to disallow inheritance from Python
- Not currently supported on PyPy
2020-04-26 09:46:44 +02:00
David Stone
5088364b96 Declare operator== and operator!= member functions const. 2020-04-26 09:20:22 +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
fwjavox
e97c735fc4 stl_bind: add binding for std::vector::clear (#2074) 2020-01-17 01:16:56 +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
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
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
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
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
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
Wenzel Jakob
34c2281e31 begin working on next version 2019-09-21 20:23:01 +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
Wenzel Jakob
31680e6f9c Implicit conversion from enum to int for Python 3.8 (fix by @sizmailov) 2019-09-20 11:06:10 +02:00
Wenzel Jakob
e825205ac6 begin working on v2.4.1 2019-09-19 23:18:04 +02:00
Wenzel Jakob
00a0aa9929 v2.4.0 release 2019-09-19 23:06:22 +02:00
Samuel Debionne
6ca312b3bc Avoid infinite recursion in is_copy_constructible (#1910) 2019-09-19 21:24:05 +02:00
Wenzel Jakob
c9f5a464bc pybind11 internals: separate different compilers 2019-09-19 21:12:14 +02:00
Sergei Izmailov
09f0829401 Avoid conversion to int_ rhs argument of enum eq/ne (#1912)
* fix: Avoid conversion to `int_` rhs argument of enum eq/ne

* test: compare unscoped enum with strings

* suppress comparison to None warning

* test unscoped enum arithmetic and comparision with unsupported type
2019-09-19 18:23:27 +02:00
Lori A. Burns
f6c4c1047a restores __invert__ to arithmetic-enabled enum, fixes #1907 (#1909) 2019-09-04 22:16:21 +02:00
Stephen Larew
5b4751af26 Add const to buffer:request() (#1890) 2019-08-27 17:05:47 +02:00
kingofpayne
12e8774bc9 Added support for list insertion. (#1888) 2019-08-19 23:00:36 +02:00
Andre Schmeißer
19189b4c2c Make overload_cast_impl available in C++11 mode. (#1581)
* Make `overload_cast_impl` available in C++11 mode.

Narrow the scope of the `#if defined(PYBIND11_CPP14)` block around overload_cast to only
cover the parts where C++14 is stricly required. Thus, the implementation in
`pybind11::details::overload_cast_impl` is still available in C++11 mode.

* PR #1581: Modify test to use overload_cast_impl, update docs and change log
2019-08-19 12:54:33 +02:00
Vladimír Vondruš
04c8f4b56e Expose BufferError among other pybind11 exceptions. (#1852) 2019-08-19 12:48:03 +02:00
Sergei Lebedev
046267c629 Added .empty() to all collection types (#1887) 2019-08-16 23:43:08 +02:00
Sergei Lebedev
08b0bda4bc Added set::contains and generalized dict::contains (#1884)
Dynamically resolving __contains__ on each call is wasteful since set
has a public PySet_Contains function.
2019-08-16 21:32:27 +02:00