Skip to content

Commit a1e9679

Browse files
Merge remote-tracking branch 'upstream/master' into feature/py_move_shared
2 parents 112a846 + a303c6f commit a1e9679

23 files changed

+168
-31
lines changed

.travis.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -193,9 +193,10 @@ install:
193193
${PYPY:+--extra-index-url https://imaginary.ca/trusty-pypi}
194194
echo "done."
195195
196-
wget -q -O eigen.tar.gz https://bitbucket.org/eigen/eigen/get/3.3.3.tar.gz
197-
tar xzf eigen.tar.gz
198-
export CMAKE_INCLUDE_PATH="${CMAKE_INCLUDE_PATH:+$CMAKE_INCLUDE_PATH:}$PWD/eigen-eigen-67e894c6cd8f"
196+
mkdir eigen
197+
curl -fsSL https://bitbucket.org/eigen/eigen/get/3.3.4.tar.bz2 | \
198+
tar --extract -j --directory=eigen --strip-components=1
199+
export CMAKE_INCLUDE_PATH="${CMAKE_INCLUDE_PATH:+$CMAKE_INCLUDE_PATH:}$PWD/eigen"
199200
fi
200201
set +e
201202
script:

CONTRIBUTING.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,18 @@ adhere to the following rules to make the process as smooth as possible:
3030
* This project has a strong focus on providing general solutions using a
3131
minimal amount of code, thus small pull requests are greatly preferred.
3232

33-
### License
33+
### Licensing of contributions
3434

3535
pybind11 is provided under a BSD-style license that can be found in the
3636
``LICENSE`` file. By using, distributing, or contributing to this project, you
3737
agree to the terms and conditions of this license.
38+
39+
You are under no obligation whatsoever to provide any bug fixes, patches, or
40+
upgrades to the features, functionality or performance of the source code
41+
("Enhancements") to anyone; however, if you choose to make your Enhancements
42+
available either publicly, or directly to the author of this software, without
43+
imposing a separate written license agreement for such Enhancements, then you
44+
hereby grant the following license: a non-exclusive, royalty-free perpetual
45+
license to install, use, modify, prepare derivative works, incorporate into
46+
other computer software, distribute, and sublicense such enhancements or
47+
derivative works thereof, in binary and source code form.

LICENSE

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,5 @@ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
2525
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2626
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2727

28-
You are under no obligation whatsoever to provide any bug fixes, patches, or
29-
upgrades to the features, functionality or performance of the source code
30-
("Enhancements") to anyone; however, if you choose to make your Enhancements
31-
available either publicly, or directly to the author of this software, without
32-
imposing a separate written license agreement for such Enhancements, then you
33-
hereby grant the following license: a non-exclusive, royalty-free perpetual
34-
license to install, use, modify, prepare derivative works, incorporate into
35-
other computer software, distribute, and sublicense such enhancements or
36-
derivative works thereof, in binary and source code form.
28+
Please also refer to the file CONTRIBUTING.md, which clarifies licensing of
29+
external contributions to this project including patches, pull requests, etc.

docs/advanced/misc.rst

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,21 @@ avoids this issue involves weak reference with a cleanup callback:
216216
// Create a weak reference with a cleanup callback and initially leak it
217217
(void) py::weakref(m.attr("BaseClass"), cleanup_callback).release();
218218
219+
.. note::
220+
221+
PyPy (at least version 5.9) does not garbage collect objects when the
222+
interpreter exits. An alternative approach (which also works on CPython) is to use
223+
the :py:mod:`atexit` module [#f7]_, for example:
224+
225+
.. code-block:: cpp
226+
227+
auto atexit = py::module::import("atexit");
228+
atexit.attr("register")(py::cpp_function([]() {
229+
// perform cleanup here -- this function is called with the GIL held
230+
}));
231+
232+
.. [#f7] https://docs.python.org/3/library/atexit.html
233+
219234
220235
Generating documentation using Sphinx
221236
=====================================

docs/changelog.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ v2.3.0 (Not yet released)
1818
* Added support for write only properties.
1919
`#1144 <https://github.com/pybind/pybind11/pull/1144>`_.
2020

21+
* The ``value()`` method of ``py::enum_`` now accepts an optional docstring
22+
that will be shown in the documentation of the associated enumeration.
23+
2124
v2.2.1 (September 14, 2017)
2225
-----------------------------------------------------
2326

docs/faq.rst

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,3 +241,19 @@ Common gotchas to watch out for involve not ``free()``-ing memory region
241241
that that were ``malloc()``-ed in another shared library, using data
242242
structures with incompatible ABIs, and so on. pybind11 is very careful not
243243
to make these types of mistakes.
244+
245+
How to cite this project?
246+
=========================
247+
248+
We suggest the following BibTeX template to cite pybind11 in scientific
249+
discourse:
250+
251+
.. code-block:: bash
252+
253+
@misc{pybind11,
254+
author = {Wenzel Jakob and Jason Rhinelander and Dean Moldovan},
255+
year = {2017},
256+
note = {https://github.com/pybind/pybind11},
257+
title = {pybind11 -- Seamless operability between C++11 and Python}
258+
}
259+

include/pybind11/cast.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1097,11 +1097,12 @@ struct type_caster<T, enable_if_t<std::is_arithmetic<T>::value && !is_std_char_t
10971097
static handle cast(T src, return_value_policy /* policy */, handle /* parent */) {
10981098
if (std::is_floating_point<T>::value) {
10991099
return PyFloat_FromDouble((double) src);
1100-
} else if (sizeof(T) <= sizeof(long)) {
1100+
} else if (sizeof(T) <= sizeof(ssize_t)) {
1101+
// This returns a long automatically if needed
11011102
if (std::is_signed<T>::value)
1102-
return PyLong_FromLong((long) src);
1103+
return PYBIND11_LONG_FROM_SIGNED(src);
11031104
else
1104-
return PyLong_FromUnsignedLong((unsigned long) src);
1105+
return PYBIND11_LONG_FROM_UNSIGNED(src);
11051106
} else {
11061107
if (std::is_signed<T>::value)
11071108
return PyLong_FromLongLong((long long) src);
@@ -1864,7 +1865,7 @@ template <typename T, typename SFINAE> type_caster<T, SFINAE> &load_type(type_ca
18641865
throw cast_error("Unable to cast Python instance to C++ type (compile in debug mode for details)");
18651866
#else
18661867
throw cast_error("Unable to cast Python instance of type " +
1867-
(std::string) str(handle.get_type()) + " to C++ type '" + type_id<T>() + "''");
1868+
(std::string) str(handle.get_type()) + " to C++ type '" + type_id<T>() + "'");
18681869
#endif
18691870
}
18701871
return conv;

include/pybind11/complex.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,13 @@ template <typename T> struct format_descriptor<std::complex<T>, detail::enable_i
2525
static std::string format() { return std::string(value); }
2626
};
2727

28+
#ifndef PYBIND11_CPP17
29+
2830
template <typename T> constexpr const char format_descriptor<
2931
std::complex<T>, detail::enable_if_t<std::is_floating_point<T>::value>>::value[3];
3032

33+
#endif
34+
3135
NAMESPACE_BEGIN(detail)
3236

3337
template <typename T> struct is_fmt_numeric<std::complex<T>, detail::enable_if_t<std::is_floating_point<T>::value>> {

include/pybind11/detail/common.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,8 @@
158158
#define PYBIND11_BYTES_SIZE PyBytes_Size
159159
#define PYBIND11_LONG_CHECK(o) PyLong_Check(o)
160160
#define PYBIND11_LONG_AS_LONGLONG(o) PyLong_AsLongLong(o)
161+
#define PYBIND11_LONG_FROM_SIGNED(o) PyLong_FromSsize_t((ssize_t) o)
162+
#define PYBIND11_LONG_FROM_UNSIGNED(o) PyLong_FromSize_t((size_t) o)
161163
#define PYBIND11_BYTES_NAME "bytes"
162164
#define PYBIND11_STRING_NAME "str"
163165
#define PYBIND11_SLICE_OBJECT PyObject
@@ -180,6 +182,8 @@
180182
#define PYBIND11_BYTES_SIZE PyString_Size
181183
#define PYBIND11_LONG_CHECK(o) (PyInt_Check(o) || PyLong_Check(o))
182184
#define PYBIND11_LONG_AS_LONGLONG(o) (PyInt_Check(o) ? (long long) PyLong_AsLong(o) : PyLong_AsLongLong(o))
185+
#define PYBIND11_LONG_FROM_SIGNED(o) PyInt_FromSsize_t((ssize_t) o) // Returns long if needed.
186+
#define PYBIND11_LONG_FROM_UNSIGNED(o) PyInt_FromSize_t((size_t) o) // Returns long if needed.
183187
#define PYBIND11_BYTES_NAME "str"
184188
#define PYBIND11_STRING_NAME "unicode"
185189
#define PYBIND11_SLICE_OBJECT PySliceObject
@@ -803,9 +807,13 @@ template <typename T> struct format_descriptor<T, detail::enable_if_t<std::is_ar
803807
static std::string format() { return std::string(1, c); }
804808
};
805809

810+
#if !defined(PYBIND11_CPP17)
811+
806812
template <typename T> constexpr const char format_descriptor<
807813
T, detail::enable_if_t<std::is_arithmetic<T>::value>>::value[2];
808814

815+
#endif
816+
809817
/// RAII wrapper that temporarily clears any Python error state
810818
struct error_scope {
811819
PyObject *type, *value, *trace;

include/pybind11/eigen.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@
1717
# pragma GCC diagnostic push
1818
# pragma GCC diagnostic ignored "-Wconversion"
1919
# pragma GCC diagnostic ignored "-Wdeprecated-declarations"
20+
# ifdef __clang__
21+
// Eigen generates a bunch of implicit-copy-constructor-is-deprecated warnings with -Wdeprecated
22+
// under Clang, so disable that warning here:
23+
# pragma GCC diagnostic ignored "-Wdeprecated"
24+
# endif
2025
# if __GNUC__ >= 7
2126
# pragma GCC diagnostic ignored "-Wint-in-bool-context"
2227
# endif

0 commit comments

Comments
 (0)