Skip to content

Merge 'upstream/master' (07e2259) from previous merge-base (12e8774) #34

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
8f5a8ab
Don't strip debug symbols in RelWithDebInfo mode (#1892)
Nekrolm Aug 23, 2019
5b4751a
Add const to buffer:request() (#1890)
slarew Aug 27, 2019
f6c4c10
restores __invert__ to arithmetic-enabled enum, fixes #1907 (#1909)
loriab Sep 4, 2019
09f0829
Avoid conversion to `int_` rhs argument of enum eq/ne (#1912)
sizmailov Sep 19, 2019
c9f5a46
pybind11 internals: separate different compilers
wjakob Sep 19, 2019
6ca312b
Avoid infinite recursion in is_copy_constructible (#1910)
sdebionne Sep 19, 2019
00a0aa9
v2.4.0 release
wjakob Sep 19, 2019
e825205
begin working on v2.4.1
wjakob Sep 19, 2019
21d0eb4
Fix Python 3.8 test regression
wjakob Sep 20, 2019
5fd187e
minor changelog cleanup
wjakob Sep 20, 2019
31680e6
Implicit conversion from enum to int for Python 3.8 (fix by @sizmailov)
wjakob Sep 20, 2019
e44fcc3
v2.4.1 release
wjakob Sep 20, 2019
82cf793
begin working on next version
wjakob Sep 20, 2019
f3109d8
future-proof Python version check from commit 31680e6 (@lgritz)
wjakob Sep 21, 2019
7f5dad7
Remove usage of C++14 constructs (fixes #1929)
wjakob Sep 21, 2019
7ec2ddf
v2.4.2 release
wjakob Sep 21, 2019
2abd7e1
updated release.rst to remove parts that are now automated
wjakob Sep 21, 2019
34c2281
begin working on next version
wjakob Sep 21, 2019
96be2c1
Fix version mismatch typos in .travis.yml (#1948)
dalboris Oct 6, 2019
6cb584e
Adapt to python3.8 C API change (#1950)
sizmailov Oct 8, 2019
80d4524
v2.4.3 release
wjakob Oct 14, 2019
dfde155
begin working on next version
wjakob Oct 14, 2019
de5a29c
Fix build with -Wmissing-prototypes (#1954)
nicolov Oct 17, 2019
6c29cbf
misleading comment corrected (strides in buffer_info is bytes and not…
rikigigi Oct 18, 2019
759221f
Obey __cpp_sized_deallocation and __cpp_aligned_new
jwnimmer-tri Jun 14, 2019
c27a6e1
make builds with python tests and cpp tests fail if either one fails …
HDembinski Oct 22, 2019
bdf6a5e
Report type names in return value policy-related cast exceptions (#1965)
HDembinski Oct 23, 2019
a83d69e
test pair-copyability on C++17 upwards (#1886)
sgsaenger Oct 31, 2019
a6355b0
CMake: Add Python 3.8 to pybind11Tools (#1974)
ax3l Oct 31, 2019
6f11347
Prevent cmake error when prefix empty (#1986)
mattdawkins Nov 14, 2019
b32b762
Fixing minor typo in basics.rst (#1984)
matsen Nov 14, 2019
55ff464
Fixing SystemError when nb_bool/nb_nonzero sets a Python exception in…
YannickJadoul Nov 14, 2019
deb3cb2
Add exception translation for std::overflow_error. (#1977)
bluescarni Nov 14, 2019
bd24155
Aligned allocation fix for clang-cl (#1988)
bluescarni Nov 16, 2019
dc65d66
support for readonly buffers (#863) (#1466)
skoslowski Nov 24, 2019
0f1d3bf
Add FAQ entry for dealing with long functions interruption (#2000)
CharlesB2 Nov 25, 2019
baf6934
Minor modifications to interrupt handling FAQ (#2007)
eacousineau Nov 25, 2019
61e4f11
numpy.h: minor preprocessor fix suggested by @chaekwan
wjakob Nov 28, 2019
a606482
Revert "numpy.h: minor preprocessor fix suggested by @chaekwan"
wjakob Nov 28, 2019
3735249
Install headers using both headers and package_data (#1995)
isuruf Nov 28, 2019
fe2a06e
Pin breathe to 4.13.1
bstaletic Dec 11, 2019
dc9006d
Use newer macOS image for python3 testing
bstaletic Dec 11, 2019
819802d
Fix a memory leak when creating Python3 modules. (#2019)
T045T Dec 11, 2019
fb910ae
Revert "Fix a memory leak when creating Python3 modules. (#2019)"
wjakob Dec 11, 2019
1376eb0
Free tstate on python 3.7+ on finalize_interpreter (#2020)
bstaletic Dec 12, 2019
b4e5d58
undo #define copysign in pyconfig.h
wjakob Dec 13, 2019
37d04ab
Fixes #1295: Handle debug interpreter (#2025)
JGamache-autodesk Dec 19, 2019
6e39b76
Add C++20 char8_t/u8string support (#2026)
VemundH Dec 19, 2019
f9f3bd7
Use C++17 fold expressions when casting tuples and argument lists (#2…
wjakob Dec 30, 2019
2fda9d5
Travis CI fix (MacOS, Py3)
wjakob Dec 31, 2019
4c206e8
bindings for import_error exception
wjakob Jan 2, 2020
bf2b031
Handle cases where binding code immediately throws py::error_already_set
wjakob Jan 2, 2020
370a2ae
Declare call_impl() as && (#2057)
rhaschke Jan 5, 2020
07e2259
Fix compilation with MinGW only (#2053)
Baljak Jan 5, 2020
6ca4163
Merge 'upstream/master' (07e2259) from previous merge-base (12e8774)
EricCousineau-TRI Jan 14, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 33 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ matrix:
- PY_CMD=python3
- $PY_CMD -m pip install --user --upgrade pip wheel setuptools
install:
- $PY_CMD -m pip install --user --upgrade sphinx sphinx_rtd_theme breathe flake8 pep8-naming pytest
# breathe 4.14 doesn't work with bit fields. See https://github.com/michaeljones/breathe/issues/462
- $PY_CMD -m pip install --user --upgrade sphinx sphinx_rtd_theme breathe==4.13.1 flake8 pep8-naming pytest
- curl -fsSL https://sourceforge.net/projects/doxygen/files/rel-1.8.15/doxygen-1.8.15.linux.bin.tar.gz/download | tar xz
- export PATH="$PWD/doxygen-1.8.15/bin:$PATH"
script:
Expand All @@ -33,8 +34,7 @@ matrix:
- |
# Barebones build
cmake -DCMAKE_BUILD_TYPE=Debug -DPYBIND11_WERROR=ON -DDOWNLOAD_CATCH=ON -DPYTHON_EXECUTABLE=$(which $PY_CMD) .
make pytest -j 2
make cpptest -j 2
make pytest -j 2 && make cpptest -j 2
# The following are regular test configurations, including optional dependencies.
# With regard to each other they differ in Python version, C++ standard and compiler.
- os: linux
Expand Down Expand Up @@ -62,7 +62,7 @@ matrix:
- os: linux
dist: trusty
env: PYTHON=2.7 CPP=14 GCC=6 CMAKE=1
name: Python 2.7, c++14, gcc 4.8, CMake test
name: Python 2.7, c++14, gcc 6, CMake test
addons:
apt:
sources:
Expand Down Expand Up @@ -107,13 +107,39 @@ matrix:
- lld-7
- libc++-7-dev
- libc++abi-7-dev # Why is this necessary???
- os: linux
dist: xenial
env: PYTHON=3.8 CPP=17 GCC=7
name: Python 3.8, c++17, gcc 7 (w/o numpy/scipy) # TODO: update build name when the numpy/scipy wheels become available
addons:
apt:
sources:
- deadsnakes
- ubuntu-toolchain-r-test
packages:
- g++-7
- python3.8-dev
- python3.8-venv
# Currently there is no numpy/scipy wheels available for python3.8
# TODO: remove next before_install, install and script clause when the wheels become available
before_install:
- pyenv global $(pyenv whence 2to3) # activate all python versions
- PY_CMD=python3
- $PY_CMD -m pip install --user --upgrade pip wheel setuptools
install:
- $PY_CMD -m pip install --user --upgrade pytest
script:
- |
# Barebones build
cmake -DCMAKE_BUILD_TYPE=Debug -DPYBIND11_WERROR=ON -DDOWNLOAD_CATCH=ON -DPYTHON_EXECUTABLE=$(which $PY_CMD) .
make pytest -j 2 && make cpptest -j 2
- os: osx
name: Python 2.7, c++14, AppleClang 7.3, CMake test
osx_image: xcode7.3
env: PYTHON=2.7 CPP=14 CLANG CMAKE=1
- os: osx
name: Python 3.7, c++14, AppleClang 9, Debug build
osx_image: xcode9
osx_image: xcode9.4
env: PYTHON=3.7 CPP=14 CLANG DEBUG=1
# Test a PyPy 2.7 build
- os: linux
Expand All @@ -131,7 +157,7 @@ matrix:
dist: trusty
services: docker
env: DOCKER=i386/debian:stretch PYTHON=3.5 CPP=14 GCC=6 INSTALL=1
name: Python 3.4, c++14, gcc 6, 32-bit
name: Python 3.5, c++14, gcc 6, 32-bit
script:
- |
# Consolidated 32-bit Docker Build + Install
Expand Down Expand Up @@ -194,7 +220,7 @@ before_install:
PY_CMD=python$PYTHON
if [ "$TRAVIS_OS_NAME" = "osx" ]; then
if [ "$PY" = "3" ]; then
brew update && brew upgrade python
brew update && brew unlink python@2 && brew upgrade python
else
curl -fsSL https://bootstrap.pypa.io/get-pip.py | $PY_CMD - --user
fi
Expand Down
2 changes: 2 additions & 0 deletions docs/advanced/exceptions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ exceptions:
+--------------------------------------+--------------------------------------+
| :class:`std::range_error` | ``ValueError`` |
+--------------------------------------+--------------------------------------+
| :class:`std::overflow_error` | ``OverflowError`` |
+--------------------------------------+--------------------------------------+
| :class:`pybind11::stop_iteration` | ``StopIteration`` (used to implement |
| | custom iterators) |
+--------------------------------------+--------------------------------------+
Expand Down
2 changes: 1 addition & 1 deletion docs/basics.rst
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ load and execute the example:
Keyword arguments
=================

With a simple modification code, it is possible to inform Python about the
With a simple code modification, it is possible to inform Python about the
names of the arguments ("i" and "j" in this case).

.. code-block:: cpp
Expand Down
77 changes: 75 additions & 2 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,86 @@ Changelog
Starting with version 1.8.0, pybind11 releases use a `semantic versioning
<http://semver.org>`_ policy.

v2.4.3 (Oct 15, 2019)
-----------------------------------------------------

* Adapt pybind11 to a C API convention change in Python 3.8. `#1950
<https://github.com/pybind/pybind11/pull/1950>`_.

v2.4.2 (Sep 21, 2019)
-----------------------------------------------------

* Replaced usage of a C++14 only construct. `#1929
<https://github.com/pybind/pybind11/pull/1929>`_.

* Made an ifdef future-proof for Python >= 4. `f3109d
<https://github.com/pybind/pybind11/commit/f3109d>`_.

v2.4.1 (Sep 20, 2019)
-----------------------------------------------------

* Fixed a problem involving implicit conversion from enumerations to integers
on Python 3.8. `#1780 <https://github.com/pybind/pybind11/pull/1780>`_.

v2.3.1 (Not yet released)
v2.4.0 (Sep 19, 2019)
-----------------------------------------------------

* Try harder to keep pybind11-internal data structures separate when there
are potential ABI incompatibilities. Fixes crashes that occurred when loading
multiple pybind11 extensions that were e.g. compiled by GCC (libstdc++)
and Clang (libc++).
`#1588 <https://github.com/pybind/pybind11/pull/1588>`_ and
`c9f5a <https://github.com/pybind/pybind11/commit/c9f5a>`_.

* Added support for ``__await__``, ``__aiter__``, and ``__anext__`` protocols.
`#1842 <https://github.com/pybind/pybind11/pull/1842>`_.

* ``pybind11_add_module()``: don't strip symbols when compiling in
``RelWithDebInfo`` mode. `#1980
<https://github.com/pybind/pybind11/pull/1980>`_.

* ``enum_``: Reproduce Python behavior when comparing against invalid values
(e.g. ``None``, strings, etc.). Add back support for ``__invert__()``.
`#1912 <https://github.com/pybind/pybind11/pull/1912>`_,
`#1907 <https://github.com/pybind/pybind11/pull/1907>`_.

* List insertion operation for ``py::list``.
Added ``.empty()`` to all collection types.
Added ``py::set::contains()`` and ``py::dict::contains()``.
`#1887 <https://github.com/pybind/pybind11/pull/1887>`_,
`#1884 <https://github.com/pybind/pybind11/pull/1884>`_,
`#1888 <https://github.com/pybind/pybind11/pull/1888>`_.

* ``py::details::overload_cast_impl`` is available in C++11 mode, can be used
like ``overload_cast`` with an additional set of parantheses.
`1581 <https://github.com/pybind/pybind11/pull/1581>`_.
`#1581 <https://github.com/pybind/pybind11/pull/1581>`_.

* Fixed ``get_include()`` on Conda.
`#1877 <https://github.com/pybind/pybind11/pull/1877>`_.

* ``stl_bind.h``: negative indexing support.
`#1882 <https://github.com/pybind/pybind11/pull/1882>`_.

* Minor CMake fix to add MinGW compatibility.
`#1851 <https://github.com/pybind/pybind11/pull/1851>`_.

* GIL-related fixes.
`#1836 <https://github.com/pybind/pybind11/pull/1836>`_,
`8b90b <https://github.com/pybind/pybind11/commit/8b90b>`_.

* Other very minor/subtle fixes and improvements.
`#1329 <https://github.com/pybind/pybind11/pull/1329>`_,
`#1910 <https://github.com/pybind/pybind11/pull/1910>`_,
`#1863 <https://github.com/pybind/pybind11/pull/1863>`_,
`#1847 <https://github.com/pybind/pybind11/pull/1847>`_,
`#1890 <https://github.com/pybind/pybind11/pull/1890>`_,
`#1860 <https://github.com/pybind/pybind11/pull/1860>`_,
`#1848 <https://github.com/pybind/pybind11/pull/1848>`_,
`#1821 <https://github.com/pybind/pybind11/pull/1821>`_,
`#1837 <https://github.com/pybind/pybind11/pull/1837>`_,
`#1833 <https://github.com/pybind/pybind11/pull/1833>`_,
`#1748 <https://github.com/pybind/pybind11/pull/1748>`_,
`#1852 <https://github.com/pybind/pybind11/pull/1852>`_.

v2.3.0 (June 11, 2019)
-----------------------------------------------------
Expand Down
4 changes: 2 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@
# built documents.
#
# The short X.Y version.
version = '2.3'
version = '2.4'
# The full version, including alpha/beta/rc tags.
release = '2.3.dev1'
release = '2.4.dev4'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
27 changes: 27 additions & 0 deletions docs/faq.rst
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,33 @@ that that were ``malloc()``-ed in another shared library, using data
structures with incompatible ABIs, and so on. pybind11 is very careful not
to make these types of mistakes.

How can I properly handle Ctrl-C in long-running functions?
===========================================================

Ctrl-C is received by the Python interpreter, and holds it until the GIL
is released, so a long-running function won't be interrupted.

To interrupt from inside your function, you can use the ``PyErr_CheckSignals()``
function, that will tell if a signal has been raised on the Python side. This
function merely checks a flag, so its impact is negligible. When a signal has
been received, you must either explicitly interrupt execution by throwing
``py::error_already_set`` (which will propagate the existing
``KeyboardInterrupt``), or clear the error (which you usually will not want):

.. code-block:: cpp

PYBIND11_MODULE(example, m)
{
m.def("long running_func", []()
{
for (;;) {
if (PyErr_CheckSignals() != 0)
throw py::error_already_set();
// Long running iteration
}
});
}

Inconsistent detection of Python version in CMake and pybind11
==============================================================

Expand Down
4 changes: 0 additions & 4 deletions docs/release.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@ To release a new version of pybind11:
- ``git push --tags``.
- ``python setup.py sdist upload``.
- ``python setup.py bdist_wheel upload``.
- Update conda-forge (https://github.com/conda-forge/pybind11-feedstock) via PR
- download release package from Github: ``wget https://github.com/pybind/pybind11/archive/vX.Y.Z.tar.gz``
- compute checksum: ``shasum -a 256 vX.Y.Z.tar.gz``
- change version number and checksum in ``recipe/meta.yml``
- Get back to work
- Update ``_version.py`` (add 'dev' and increment minor).
- Update version in ``docs/conf.py``
Expand Down
30 changes: 18 additions & 12 deletions include/pybind11/buffer_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,34 +21,39 @@ struct buffer_info {
std::string format; // For homogeneous buffers, this should be set to format_descriptor<T>::format()
ssize_t ndim = 0; // Number of dimensions
std::vector<ssize_t> shape; // Shape of the tensor (1 entry per dimension)
std::vector<ssize_t> strides; // Number of entries between adjacent entries (for each per dimension)
std::vector<ssize_t> strides; // Number of bytes between adjacent entries (for each per dimension)
bool readonly = false; // flag to indicate if the underlying storage may be written to

buffer_info() { }

buffer_info(void *ptr, ssize_t itemsize, const std::string &format, ssize_t ndim,
detail::any_container<ssize_t> shape_in, detail::any_container<ssize_t> strides_in)
detail::any_container<ssize_t> shape_in, detail::any_container<ssize_t> strides_in, bool readonly=false)
: ptr(ptr), itemsize(itemsize), size(1), format(format), ndim(ndim),
shape(std::move(shape_in)), strides(std::move(strides_in)) {
shape(std::move(shape_in)), strides(std::move(strides_in)), readonly(readonly) {
if (ndim != (ssize_t) shape.size() || ndim != (ssize_t) strides.size())
pybind11_fail("buffer_info: ndim doesn't match shape and/or strides length");
for (size_t i = 0; i < (size_t) ndim; ++i)
size *= shape[i];
}

template <typename T>
buffer_info(T *ptr, detail::any_container<ssize_t> shape_in, detail::any_container<ssize_t> strides_in)
: buffer_info(private_ctr_tag(), ptr, sizeof(T), format_descriptor<T>::format(), static_cast<ssize_t>(shape_in->size()), std::move(shape_in), std::move(strides_in)) { }
buffer_info(T *ptr, detail::any_container<ssize_t> shape_in, detail::any_container<ssize_t> strides_in, bool readonly=false)
: buffer_info(private_ctr_tag(), ptr, sizeof(T), format_descriptor<T>::format(), static_cast<ssize_t>(shape_in->size()), std::move(shape_in), std::move(strides_in), readonly) { }

buffer_info(void *ptr, ssize_t itemsize, const std::string &format, ssize_t size)
: buffer_info(ptr, itemsize, format, 1, {size}, {itemsize}) { }
buffer_info(void *ptr, ssize_t itemsize, const std::string &format, ssize_t size, bool readonly=false)
: buffer_info(ptr, itemsize, format, 1, {size}, {itemsize}, readonly) { }

template <typename T>
buffer_info(T *ptr, ssize_t size)
: buffer_info(ptr, sizeof(T), format_descriptor<T>::format(), size) { }
buffer_info(T *ptr, ssize_t size, bool readonly=false)
: buffer_info(ptr, sizeof(T), format_descriptor<T>::format(), size, readonly) { }

template <typename T>
buffer_info(const T *ptr, ssize_t size, bool readonly=true)
: buffer_info(const_cast<T*>(ptr), sizeof(T), format_descriptor<T>::format(), size, readonly) { }

explicit buffer_info(Py_buffer *view, bool ownview = true)
: buffer_info(view->buf, view->itemsize, view->format, view->ndim,
{view->shape, view->shape + view->ndim}, {view->strides, view->strides + view->ndim}) {
{view->shape, view->shape + view->ndim}, {view->strides, view->strides + view->ndim}, view->readonly) {
this->view = view;
this->ownview = ownview;
}
Expand All @@ -70,6 +75,7 @@ struct buffer_info {
strides = std::move(rhs.strides);
std::swap(view, rhs.view);
std::swap(ownview, rhs.ownview);
readonly = rhs.readonly;
return *this;
}

Expand All @@ -81,8 +87,8 @@ struct buffer_info {
struct private_ctr_tag { };

buffer_info(private_ctr_tag, void *ptr, ssize_t itemsize, const std::string &format, ssize_t ndim,
detail::any_container<ssize_t> &&shape_in, detail::any_container<ssize_t> &&strides_in)
: buffer_info(ptr, itemsize, format, ndim, std::move(shape_in), std::move(strides_in)) { }
detail::any_container<ssize_t> &&shape_in, detail::any_container<ssize_t> &&strides_in, bool readonly)
: buffer_info(ptr, itemsize, format, ndim, std::move(shape_in), std::move(strides_in), readonly) { }

Py_buffer *view = nullptr;
bool ownview = false;
Expand Down
Loading