Commit Graph

916 Commits

Author SHA1 Message Date
Wenzel Jakob
fd3a93c520 Use C++17 fold expressions when casting tuples and argument lists
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 00:47:26 +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
Vladimír Vondruš
5b0ea77c62 Fix -Wmissing-prototypes warning on Clang. (#1863)
The -Wmissing-prototypes Clang warning (or -Wmissing-declarations on
GCC) is very useful to avoid accidents where a function definition in a
source file doesn't match the corresponding declaration in a header
file, as it would warn already during compilation and not much later
during link time.

Unfortunately this means that exported functions defined only in the
source file (usually the ones annotated with `extern "C"`) will cause
this warning to be emitted too (on Clang, GCC has a slightly different
behavior with -Wmissing-declarations and doesn't warn here). This fixes
the warning by providing a declaration right before the definition.
2019-08-16 08:52:13 +02:00
ali-beep
5ef13eb680 Add negative indexing support to stl_bind. (#1882) 2019-08-15 19:41:11 +02:00
Borja Zarco
b2fdfd1228 Avoid use of lambda to work around a clang bug. (#1883)
Clang has a bug [1] in x86 Windows that is exposed by the use of lambdas with "unforwardable" prototypes. The error is "error: cannot compile this forwarded non-trivially copyable parameter yet", and the message was introduced in [2] (used to be an assertion).

[1] https://llvm.org/bugs/show_bug.cgi?id=28299
[2] feb1567e07
2019-08-15 13:42:43 +02:00
Saran Tunyasuvunakool
bdf1a2cc34 In internals.h, only look at _DEBUG when compiling with MSVC. (#1855)
* In internals.h, only look at _DEBUG when compiling with MSVC.

(_DEBUG is a MSVC-specific macro.)
2019-08-13 22:00:47 +02:00
Pauli Virtanen
c9d32a81f4 numpy: fix refcount leak to dtype singleton (#1860)
PyArray_DescrFromType returns a new reference, not borrowed one
2019-07-27 11:35:32 +02:00
Eric Cousineau
4a3464fd88 numpy: Provide concrete size aliases
Test for dtype checks now succeed without warnings
2019-07-23 13:17:20 +02:00
phil-zxx
c6b699d9c2 Added ability to convert from datetime.date to system_clock::time_point (#1848)
* Added ability to convert from Python datetime.date and datetime.time to C++ system_clock::time_point
2019-07-19 11:28:48 +02:00
Jeremy Maitin-Shepard
a3f4a0e8ab Add support for __await__, __aiter__, and __anext__ protocols (#1842) 2019-07-18 09:02:35 +02:00
Nathan
9b3fb05326 Allow Windows.h min/max to coexist with pybind11 (#1847)
* Protect std::min/max functions from windows.h min/max
Removed check for windows min/max
2019-07-18 09:01:50 +02:00
Wenzel Jakob
b2c4ff6052 renamed local gil_scoped_acquire to gil_scoped_acquire_local to avoid ambiguity 2019-07-15 17:29:13 +02:00