Commit Graph

1509 Commits

Author SHA1 Message Date
Wenzel Jakob
a23996fce3 flake8 fix 2018-11-11 21:10:09 +01:00
Wenzel Jakob
9a19306fbf bump version to 2.2.4 2018-09-11 10:12:10 +02:00
Wenzel Jakob
b29a9ebafc changelog for version 2.2.4 2018-09-11 10:09:36 +02:00
Axel Huebl
105eb6cb1f Debug Builds: -DPy_DEBUG (#1438)
builds against a python debug library were unreliable and
could lead to symbol errors during linking.

Setting the `Py_DEBUG` define is necessary when linking
against a debug build:

https://stackoverflow.com/questions/39161202/how-to-work-around-missing-pymodule-create2-in-amd64-win-python35-d-lib

https://docs.python.org/2/c-api/intro.html#debugging-builds

https://docs.python.org/3.6/c-api/intro.html#debugging-builds
2018-09-11 10:09:36 +02:00
Wenzel Jakob
64893d421b Fixed flake8 error in test_iostream.py 2018-09-11 10:09:36 +02:00
Justin Bassett
b47192f069 fix detail::pythonbuf::overflow()'s return value to return not_eof(c) (#1479) 2018-09-11 10:09:36 +02:00
Michael Goulding
d0c1d286cb VS 15.8.0 Preview 4.0 has a bug with alias templates (#1462)
* VS 15.8.0 Preview 4.0 has a bug with alias templates
2018-09-11 10:09:36 +02:00
Henry Schreiner
470e718a41 Update C++ macros for C++17 and MSVC Z mode (#1347) 2018-09-11 10:09:36 +02:00
Matthias Geier
c769c62949 fix copy-paste error: non-const -> const 2018-09-11 10:09:36 +02:00
Wenzel Jakob
3595fd06dc Eigen test suite: don't create a np.matrix 2018-09-11 10:09:36 +02:00
Jason Rhinelander
f7b27efbc9 Fix compatibility with catch v2
Catch v2 changed the `run(...)` signature to take a `char *argv[]`,
arguing partly that technically a `char *argv[]` type is the correct
`main()` signature rather than `const char *argv[]`.

Dropping the `const` here doesn't appear to cause any problems with
catch v1 (tested against both the cmake-downloaded 1.9.3 and Debian's
1.12.1 package) so we can follow suit.
2018-09-11 10:09:36 +02:00
Wenzel Jakob
a1be85f1e3 stl.h: propagate return value policies to type-specific casters (#1455)
* stl.h: propagate return value policies to type-specific casters

Return value policies for containers like those handled in in 'stl.h'
are currently broken.

The problem is that detail::return_value_policy_override<C>::policy()
always returns 'move' when given a non-pointer/reference type, e.g.
'std::vector<...>'.

This is sensible behavior for custom types that are exposed via
'py::class_<>', but it does not make sense for types that are handled by
other type casters (STL containers, Eigen matrices, etc.).

This commit changes the behavior so that
detail::return_value_policy_override only becomes active when the type
caster derives from type_caster_generic.

Furthermore, the override logic is called recursively in STL type
casters to enable key/value-specific behavior.
2018-09-11 10:09:36 +02:00
Wenzel Jakob
d3b4777cea fix regression reported by @cyfdecyf in #1454 (#1517) 2018-09-11 10:09:36 +02:00
Yannick Jadoul
c07c0c741c Switching deprecated Thread Local Storage (TLS) usage in Python 3.7 to Thread Specific Storage (TSS) (#1454)
* Switching deprecated Thread Local Storage (TLS) usage in Python 3.7 to Thread Specific Storage (TSS)

* Changing Python version from 3.6 to 3.7 for Travis CI, to match brew's version of Python 3

* Introducing PYBIND11_ macros to switch between TLS and TSS API
2018-09-11 09:57:55 +02:00
Boris Dalstein
11ee8ad5d3 Fix typo in doc: build-in -> built-in 2018-09-11 09:57:09 +02:00
Thomas Hrabe
c3171d5d32 Minor documentation clarification in numpy.rst (#1356) 2018-09-11 09:53:19 +02:00
Antony Lee
0ad58d887f Silence GCC8's -Wcast-function-type. (#1396)
* Silence GCC8's -Wcast-function-type.

See https://bugs.python.org/issue33012 and PRs linked therein.
2018-09-11 09:52:44 +02:00
Axel Huebl
13043957ce CMake: Remember Python Version (#1434)
It is useful not only to remember the python libs and includes but
also the interpreter version in cache.

If users call pybind11 throught `add_subdirectories` they will
otherwise have no access to the selected interpreter version.
The interpreter version is useful for downstream projects, e.g.
to select default `lib/pythonX.Y/site-packages/` install paths.
2018-09-11 09:51:46 +02:00
Khachajantc Michael
f52b46c5f7 Use std::addressof to obtain holder address instead of operator& 2018-09-11 09:50:21 +02:00
Maciek Starzyk
526b708f9d Update PyPI URLs 2018-09-11 09:49:49 +02:00
Axel Huebl
0dd69e2ad1 Fix Travis GCC 7 Python 3.6.6 (#1436)
Add missing python3 distutils on Debian "buster".
2018-09-11 09:49:38 +02:00
Antony Lee
c9ee873a53 Properly report exceptions thrown during module initialization.
If an exception is thrown during module initialization, the
error_already_set destructor will try to call `get_internals()` *after*
setting Python's error indicator, resulting in a `SystemError: ...
returned with an error set`.

Fix that by temporarily stashing away the error indicator in the
destructor.
2018-09-11 09:48:06 +02:00
Antony Lee
d3908be61d Clarify docs for functions taking bytes and not str. 2018-09-11 09:47:57 +02:00
David Caron
27c7697f24 Typo 2018-09-11 09:46:23 +02:00
luzpaz
a464273610 Misc. typos (#1384)
Found via `codespell`
2018-09-11 09:46:00 +02:00
Jason Rhinelander
ae6f095991 Base class destructor should be virtual
Fixes #1401
2018-09-11 09:45:16 +02:00
Naotoshi Seo
a50125ff85 Fix SEGV to create empty shaped numpy array (#1371)
Fix a segfault when creating a 0-dimension, c-strides array.
2018-09-11 09:44:19 +02:00
Lori A. Burns
abf916d845 Enforces intel icpc >= 2017, fixes #1121 (#1363) 2018-09-11 09:40:52 +02:00
Wenzel Jakob
ed07e49236 fix trailing space in changelog 2018-04-29 14:24:25 +02:00
Henry Schreiner
53782c08c0 Fix pip issues on AppVeyor CI (#1369) 2018-04-29 14:24:04 +02:00
Wenzel Jakob
8edc147d67 changelog for v2.2.3 2018-04-29 14:06:14 +02:00
Lori A. Burns
2972cb3808 Enforces intel icpc >= 2017, fixes #1121 (#1363) 2018-04-29 13:55:49 +02:00
Jason Rhinelander
97a62ebef2 Add workaround for clang 3.3/3.4
As reported in #1349, clang before 3.5 can segfault on a function-local
variable referenced inside a lambda.  This moves the function-local
static into a separate function that the lambda can invoke to avoid the
issue.

Fixes #1349
2018-04-29 13:52:59 +02:00
Jason Rhinelander
6837740bb6 Fix numpy dtypes test on big-endian architectures
This fixes the test code on big-endian architectures: the array support
(PR #832) had hard-coded the little-endian '<' but we need to use '>' on
big-endian architectures.
2018-04-29 13:52:37 +02:00
Wenzel Jakob
60306045ab Detect pybind11 header path without depending on pip internals (fixes #1174) (#1190) 2018-04-29 13:52:07 +02:00
Wenzel Jakob
f117a48ea2 mark release date in changelog 2018-02-07 10:59:22 +01:00
Jason Rhinelander
19e90dc310 Updated version/changelog for 2.2.2 2018-02-07 10:54:31 +01:00
Wenzel Jakob
ebe16361b0 Fix pybind11 interoperability with Clang trunk 2018-02-07 10:54:31 +01:00
Jason Rhinelander
f99f685160 MSVC workaround for broken using detail::_ warning
Current MSVC generates totally bizarre errors:

    error C2884: 'pybind11::detail::_': introduced by using-declaration
    conflicts with local function 'pybind11::detail::_'

which makes no sense (since the supposed "conflict" is the function
itself).  Work around it by `using namespace detail;` instead (which
also lets us drop a bunch of other `detail::` qualifications, so isn't
actually a bad thing).
2018-02-07 10:54:31 +01:00
Jason Rhinelander
c3d81d235f Use stricter brace initialization
This updates the `py::init` constructors to only use brace
initialization for aggregate initiailization if there is no constructor
with the given arguments.

This, in particular, fixes the regression in #1247 where the presence of
a `std::initializer_list<T>` constructor started being invoked for
constructor invocations in 2.2 even when there was a specific
constructor of the desired type.

The added test case demonstrates: without this change, it fails to
compile because the `.def(py::init<std::vector<int>>())` constructor
tries to invoke the `T(std::initializer_list<std::vector<int>>)`
constructor rather than the `T(std::vector<int>)` constructor.

By only using `new T{...}`-style construction when a `T(...)`
constructor doesn't exist, we should bypass this by while still allowing
`py::init<...>` to be used for aggregate type initialization (since such
types, by definition, don't have a user-declared constructor).
2018-02-07 10:54:31 +01:00
Jason Rhinelander
56c1edb46d Don't add duplicate patients
This fixes #1251 (patient vector grows without bounds) for the 2.2.2
branch by checking that the vector doesn't already have the given
patient.

This is a little less elegant than the same fix for `master` (which
changes the patients `vector` to an `unordered_set`), but that requires
an internals layout change, which this approach avoids.
2018-02-07 10:54:31 +01:00
Jason Rhinelander
20d6d1d457 Fix segfault when reloading interpreter with external modules (#1092)
* Fix segfault when reloading interpreter with external modules

When embedding the interpreter and loading external modules in that
embedded interpreter, the external module correctly shares its
internals_ptr with the one in the embedded interpreter.  When the
interpreter is shut down, however, only the `internals_ptr` local to
the embedded code is actually reset to nullptr: the external module
remains set.

The result is that loading an external pybind11 module, letting the
interpreter go through a finalize/initialize, then attempting to use
something in the external module fails because this external module is
still trying to use the old (destroyed) internals.  This causes
undefined behaviour (typically a segfault).

This commit fixes it by adding a level of indirection in the internals
path, converting the local internals variable to `internals **` instead
of `internals *`.  With this change, we can detect a stale internals
pointer and reload the internals pointer (either from a capsule or by
creating a new internals instance).

(No issue number: this was reported on gitter by @henryiii and @aoloe).
2018-02-07 10:54:31 +01:00
Jeff VanOss
17ad517d61 fix return from std::map bindings to __delitem__ (#1229)
Fix return from `std::map` bindings to `__delitem__`: we should be returning `void`, not an iterator.

Also adds a test for map item deletion.
2018-02-07 10:54:31 +01:00
luz.paz
ed0a72eb0e misc. typos
Found via `codespell`
2018-02-07 10:54:31 +01:00
Jason Rhinelander
c8f07b5d01 Use a named rather than anon struct in instance
The anonymous struct nested in a union triggers a -Wnested-anon-type
warning ("anonymous types declared in an anonymous union are an
extension") under clang (#1204).  This names the struct and defines it
out of the definition of `instance` to get around to warning (and makes
the code slightly simpler).
2018-02-07 10:54:31 +01:00
Jason Rhinelander
7f170fe4e1 Fixes for numpy 1.14.0 compatibility
- UPDATEIFCOPY is deprecated, replaced with similar (but not identical)
  WRITEBACKIFCOPY; trying to access the flag causes a deprecation
  warning under numpy 1.14, so just check the new flag there.
- Numpy `repr` formatting of floats changed in 1.14.0 to `[1., 2., 3.]`
  instead of the pre-1.14 `[ 1.,  2.,  3.]`.  Updated the tests to
  check for equality with the `repr(...)` value rather than the
  hard-coded (and now version-dependent) string representation.
2018-02-07 10:54:31 +01:00
Jason Rhinelander
8310aa4676 Added py::args ref counting tests 2018-02-07 10:54:31 +01:00
Jason Rhinelander
0c7aec480a Simplify arg copying 2018-02-07 10:54:31 +01:00
Zach DeVito
155cc7c4d2 Fix leak in var arg handling
When using the mixed position + vararg path, pybind over inc_ref's
the vararg positions. Printing the ref_count() of `item` before
and after this change you see:

Before change:

```
refcount of item before assign 3
refcount of item after assign 5
```

After change
```
refcount of item before assign 3
refcount of item after assign 4
```
2018-02-07 10:54:31 +01:00
Jason Rhinelander
c715c70e0a Fix premature destruction of args/kwargs arguments
The `py::args` or `py::kwargs` arguments aren't properly referenced
when added to the function_call arguments list: their reference counts
drop to zero if the first (non-converting) function call fails, which
means they might be cleaned up before the second pass call runs.

This commit adds a couple of extra `object`s to the `function_call`
where we can stash a reference to them when needed to tie their
lifetime to the function_call object's lifetime.

(Credit to YannickJadoul for catching and proposing a fix in #1223).
2018-02-07 10:54:31 +01:00