Commit Graph

1439 Commits

Author SHA1 Message Date
Dean Moldovan
2cf87a54d8 Fix implicit conversion of accessors to types derived from py::object
Fixes #1069.
2017-09-11 10:09:32 +02:00
Dean Moldovan
953d2422b3 Fix a reference leak in the number converter (#1078)
Fixes #1075.

`PyNumber_Float()` and `PyNumber_Long()` return new references.
2017-09-10 16:53:02 +02:00
Dean Moldovan
7b1de1e551 Fix nullptr dereference when loading an external-only module_local type 2017-09-10 12:28:03 +02:00
Dean Moldovan
3c4933cb50 Fix STL casters for containers with proxies (regression)
To avoid an ODR violation in the test suite while testing
both `stl.h` and `std_bind.h` with `std::vector<bool>`,
the `py::bind_vector<std::vector<bool>>` test is moved to
the secondary module (which does not include `stl.h`).
2017-09-10 12:25:10 +02:00
Henry Schreiner
43126201a6 Fix style script and add comment to failing blocks (#1045)
[skip appveyor]
2017-09-10 12:24:33 +02:00
Dean Moldovan
2d49aee4c5 Remove unused value assignment 2017-09-08 13:44:55 +02:00
Dean Moldovan
b0a0e4a23c Fix compilation with Clang on host GCC < 5 (old libstdc++) 2017-09-08 12:48:14 +02:00
Dean Moldovan
cdf38dc6ba Move the style check/barebones config up to the first position on Travis
This runs the most basic tests first and avoids waiting until the very
end for style checks.

[skip appveyor]
2017-09-08 12:13:42 +02:00
Dean Moldovan
b7c98d21e1 Speed up Travis CI build (#1056)
* Update Python 3 osx image to xcode8.3 to speed up brew install. 
  The Python 2 osx image remains xcode7.3.

* Have one osx config run in debug mode to improve coverage.

* Only run CMake build tests on two configs to speed up overall build.

  The CMake tests take ~30 seconds on each configuration, but we really 
  only need to them to run on two: one on Linux and one on macOS. This
  mirrors the recent change on AppVeyor.

* Merge the style/docs/pip tests with the barebones build.

* Merge 32-bit and CMake install configurations.

  This removes clang 3.9 from testing, but there are already 3 other clang 
  versions being tested on Travis and the new xcode8.3 image should be 
  close to clang 3.9.

[skip appveyor]
2017-09-08 10:59:50 +02:00
Dean Moldovan
0991d7fba1 Remove deprecated placement-new constructor from docs
[skip ci]
2017-09-07 15:02:16 +02:00
Dean Moldovan
a80af9557d Add a dummy common.h header with a deprecation warning 2017-09-06 15:22:26 +02:00
Dean Moldovan
00b8f3655d Relax py::pickle() get/set type check
Fixes #1061.

`T` and `const T &` are compatible types.
2017-09-06 15:20:52 +02:00
Dean Moldovan
7939f4b3fe Fix application of keep_alive policy to constructors (regression) 2017-09-06 10:21:11 +02:00
Marcin Wojdyr
fbab29c73a remove extra ';' [-Wpedantic] 2017-09-05 16:00:34 -04:00
Dean Moldovan
91b42c8174 Add upgrade guide entry about stricter compile-time checks
Closes #1048, closes #1052.

[skip ci]
2017-09-04 23:01:34 +02:00
Patrik Huber
1ad2227d3c Fixed typo in docs
[skip ci]
2017-09-04 23:00:19 +02:00
Bruce Merry
b490b44e34 Update documentation for keep_alive to match new implementation
PR #880 changed the implementation of keep_alive to avoid weak
references when the nurse is pybind11-registered, but the documentation
didn't get updated to match.
2017-09-01 21:38:16 +02:00
Wenzel Jakob
2fb4e9532e fix release.rst instructions for conda-forge SHA checksum
[skip ci]
2017-08-31 23:05:47 +02:00
Wenzel Jakob
8cf091a41f updated version flags for next version 2017-08-31 14:01:08 +02:00
Wenzel Jakob
2a5a5ec0a4 updated changelog.rst with release date 2017-08-31 13:58:24 +02:00
Wenzel Jakob
def3c18c65 updated variables for v2.2.0 release 2017-08-31 13:56:57 +02:00
Dean Moldovan
6898679270 Update enum_ and bind_vector to new-style init and pickle
Fixes #1046.
2017-08-31 01:28:07 +02:00
Dean Moldovan
4c5404421f Update changelog and upgrade guide
[skip ci]
2017-08-30 22:48:39 +02:00
Ivan Smirnov
5cbfda5b68 Update build commands for Linux / OS X in the docs (#907) 2017-08-30 21:58:43 +02:00
Bruce Merry
37de2da9dd Access C++ hash functions from Python and vice versa (#1034)
There are two separate additions:

1. `py::hash(obj)` is equivalent to the Python `hash(obj)`.
2. `.def(hash(py::self))` registers the hash function defined by
   `std::hash<T>` as the Python hash function.
2017-08-30 14:22:00 +02:00
Florian Apolloner
29b99a11a4 Specify CXX as project language for CMake >= 3.4 (#1027) 2017-08-30 14:17:54 +02:00
Dean Moldovan
b8c5dbdef5 Show a deprecation warning for old-style __init__ and __setstate__
The warning is shown at module initialization time (on import, not
when the functions are called). It's only visible when compiled in
debug mode.
2017-08-30 11:11:38 +02:00
Dean Moldovan
1e5a7da30d Add py::pickle() adaptor for safer __getstate__/__setstate__ bindings
This is analogous to `py::init()` vs `__init__` + placement-new.
`py::pickle()` reuses most of the implementation details of `py::init()`.
2017-08-30 11:11:38 +02:00
Wenzel Jakob
a1041190c8 mention PR #1037 in changelog 2017-08-28 16:35:32 +02:00
Wenzel Jakob
8ed5b8ab55 make implicit conversions non-reentrant (fixes #1035) (#1037) 2017-08-28 16:34:06 +02:00
Dean Moldovan
15f36d2b2d Simplify py::init() type deduction and error checking 2017-08-28 16:08:53 +02:00
Dean Moldovan
39fd6a9463 Reduce binary size overhead of new-style constructors
The lookup of the `self` type and value pointer are moved out of
template code and into `dispatcher`. This brings down the binary
size of constructors back to the level of the old placement-new
approach. (It also avoids a second lookup for `init_instance`.)

With this implementation, mixing old- and new-style constructors
in the same overload set may result in some runtime overhead for
temporary allocations/deallocations, but this should be fine as
old style constructors are phased out.
2017-08-28 16:08:53 +02:00
Dean Moldovan
93528f57f3 Document that type_caster requires default-constructible types
[skip ci]
2017-08-28 14:58:11 +02:00
Wenzel Jakob
5f317e60bd extended module destructor documentation (#1031) 2017-08-26 00:35:05 +02:00
Dean Moldovan
c40ef612cc Skip boost::variant tests on unsupported compilers and versions of Boost 2017-08-25 21:11:36 +02:00
Wenzel Jakob
c14c2762f6 Address reference leak issue (fixes #1029)
Creating an instance of of a pybind11-bound type caused a reference leak in the
associated Python type object, which could prevent these from being collected
upon interpreter shutdown. This commit fixes that issue for all types that are
defined in a scope (e.g. a module). Unscoped anonymous types (e.g. custom
iterator types) always retain a positive reference count to prevent their
collection.
2017-08-25 16:02:18 +02:00
Henry Schreiner
8b40505575 Utility for redirecting C++ streams to Python (#1009) 2017-08-25 02:12:43 +02:00
Dean Moldovan
3d8df5af03 Fix missing user dir in python -m pybind11 --includes
For the case of `pip install --user`, the header include dirs must
also include `pybind11.get_include(True)`.

[skip appveyor]
2017-08-24 13:55:43 +02:00
Dean Moldovan
1913f252d3 Fix setup.py detail headers and add pip install tests to Travis
The default `install_headers` from `distutils` flattens all the headers
into a single directory -- `detail` subdirectory was lost. This commit
fixes this by overriding the setup with a custom header installer.

Tests are added to Travis to make sure `setup.py sdist` and `pip install`
do not miss any headers and that the directory structure is preserved.

[skip appveyor]
2017-08-24 13:55:43 +02:00
Matthias Hochsteger
e8b5074187 Fix wrong link in changelog 2017-08-23 12:06:30 -04:00
Jason Rhinelander
e9bb843edc Fix clang5 warnings 2017-08-23 12:05:18 -04:00
Jason Rhinelander
b97510388f Change clang-4 travis-ci build to clang-5
Newer clang produces additional warnings.

[skip appveyor]
2017-08-23 12:05:18 -04:00
Dean Moldovan
b33475d054 Speed up AppVeyor build (#1021)
The `latest` build remains as is, but all others are modified to:

* Use regular Python instead of conda. `pip install` is much faster
  than conda, but scipy isn't available. Numpy is still tested.

* Compile in debug mode instead of release.

* Skip CMake build tests. For some reason, CMake configuration is very
  slow on AppVeyor and these tests are almost entirely CMake.

The changes reduce build time to about 1/3 of the original. The `latest` 
config still covers scipy, release mode and the CMake build tests, so 
the others don't need to.
2017-08-23 17:18:57 +02:00
Wenzel Jakob
b12a9d67c6 mention PR #1015 in changelog 2017-08-23 16:30:56 +02:00
Dean Moldovan
4bacd7dec1 Remove noinline from internal static locals 2017-08-23 10:44:52 +02:00
Dean Moldovan
669aa29461 Improve type safety of internals.registered_types_cpp 2017-08-23 10:44:52 +02:00
Dean Moldovan
96997a4b9d Change internals ID and versioning scheme to avoid module conflicts
The current PYBIND11_INTERNALS_ID depends on the version of the library
in order to isolate binary incompatible internals capsules. However,
this does not preclude conflicts between modules built from different
(binary incompatible) commits with the same version number.

For example, if one module was built with an early v2.2.dev and
submitted to PyPI, it could not be loaded alongside a v2.2.x release
module -- it would segfault because of incompatible internals with
the same ID.

This PR changes the ID to depend on PYBIND11_INTERNALS_VERSION which is
independent of the main library version. It's an integer which should be
incremented whenever a binary incompatible change is made to internals.

PYBIND11_INTERNALS_KIND is also introduced for a similar reason.

The same versioning scheme is also applied to `type_info` and the
`module_local` type attribute.
2017-08-23 10:44:52 +02:00
Dean Moldovan
024932b379 Move everything related to internals into a separate detail header 2017-08-23 10:44:52 +02:00
Baljak
3271fecfde Fix is_template_base_of on VS with LLVM/Intel toolset (#1020) 2017-08-23 00:45:30 +02:00
Wenzel Jakob
4336a7da4a support for brace initialization 2017-08-22 16:22:56 +02:00