Commit Graph

2164 Commits

Author SHA1 Message Date
Robert Haschke
f2226aefe0
Allow perfect forwarding of method args (#2048) 2020-07-07 15:56:07 +02:00
Dustin Spicuzza
1b0bf352fa
Throw TypeError when subclasses forget to call __init__ (#2152)
- Fixes #2103
2020-07-07 12:04:06 +02:00
Yannick Jadoul
d54d6d8c61
Adding pybind11::cast overload for rvalue references (#1260)
* Adding pybind11::cast overload for rvalue references
2020-07-01 01:53:09 +02:00
Wenzel Jakob
fc3a4490b8 Minor clarification (@AntoinePrv, #2083) 2020-07-01 00:29:55 +02:00
Nils Leif Fischer
141e8cc0af Fix uninitialized-variables cmake warnings 2020-07-01 00:19:25 +02:00
Takahiro Ishikawa
3618807dca Fix python.lib name
pybind11_add_module fails because FindPythonLibsNew.cmake try to link PythonXX.lib, but the first letter "p" should be lowercase.
2020-07-01 00:14:24 +02:00
Guilherme Dantas
8908552dfc typo 2020-07-01 00:12:33 +02:00
Lin Hsu
d031efe788 Typo 2020-07-01 00:08:05 +02:00
B Krishna Chaitanya
714424387f Refactor: Extract Custom Type Casts related tests 2020-07-01 00:07:49 +02:00
Boris Staletic
ae2ee2a4a5 Avoid using deprecated API in python 3.9
The PyEval_InitThreads() and PyEval_ThreadsInitialized() functions are
now deprecated and will be removed in Python 3.11. Calling
PyEval_InitThreads() now does nothing. The GIL is initialized by
Py_Initialize() since Python 3.7.
2020-06-30 23:50:23 +02:00
fatvlady
f99ff736c2 Add additional check to be more compliant with other casters 2020-06-29 21:01:20 +02:00
fatvlady
8c06b95492 Fix compile error on GCC4.8 2020-06-29 21:01:20 +02:00
fatvlady
556277d689 Fix optional dereference type deduction 2020-06-29 21:01:20 +02:00
fatvlady
a3daf87d45 Add failing optional test 2020-06-29 21:01:20 +02:00
Ashley Whetter
8e85fadff2 Render py::none as None in docstrings
Closes #2270
2020-06-29 11:48:44 +02:00
Wenzel Jakob
8c0cd94465 ignore another type of visual studio project file 2020-06-18 12:14:59 +02:00
methylDragon
d96c34516d Fix docs typo 2020-06-15 23:19:19 +02:00
Isuru Fernando
e107fc2a05 Fix setuptools record of headers 2020-06-11 00:21:50 +02:00
Sergei Izmailov
ab323e04f3 Test py::iterable/py::iterator representation in docstrings 2020-06-10 13:36:31 +02:00
Sergei Izmailov
4f1531c454 Render py::int_ as int in docstrings 2020-06-10 13:36:31 +02:00
Sergei Izmailov
90d99b56a0 Render pybind11::array as numpy.ndarray in docstrings 2020-06-10 13:36:31 +02:00
Sergei Izmailov
57070fb0a0 Render py::iterator/py::iterable as Iterator/Iterable in docstrings 2020-06-10 13:36:31 +02:00
Sergei Izmailov
22b2504080 Render full numpy numeric names (e.g. numpy.int32) 2020-06-10 13:36:31 +02:00
Clemens Sielaff
63df87fa49
Add lvalue ref-qualified cpp_function constructors (#2213)
* added overload for l-value ref-qualified methods

* Added test.
Before, the code would have failed to build.
2020-06-10 13:35:10 +02:00
Matthijs van der Burgh
b524008967
Deepcopy documentation (#2242)
* (docs) convert note to real note

* (docs) Add information about (deep)copy
2020-06-10 13:30:41 +02:00
Thomas Köppe
1e14930dfc [common.h] Mark another entry point as "unused".
For rationale, see #2241, eeb1044818af5b70761deae602c49eba439164dc;
there is a second entry point function defined by the PYBIND11_MODULE
macro that also needs to be annotated as unused.
2020-06-10 13:27:10 +02:00
Simeon Ehrig
c776e9ef93 Fix compiler error with MSVC 17 and CUDA 10.2 2020-06-09 01:57:57 +02:00
Thomas Köppe
eeb1044818 [common.h] Mark entry point as "unused".
This change defines a new, portable macro PYBIND11_MAYBE_UNUSED to
mark declarations as unused, and annotates the PYBIND11_MODULE entry
point with this attribute.

The purpose of this annotation is to facilitate dead code detection,
which might otherwise consider the module entry point function dead,
since it isn't otherwise used. (It is only used via FFI.)
2020-06-05 01:53:26 +02:00
Andrey Dorozhkin
1817d2116a Disable defining (v)snprintf as macro in modern Visual Studio 2020-06-05 01:49:13 +02:00
Eric Cousineau
4e3d9fea74 operators: Explicitly expose py::hash(py::self)
Add warnings about extending STL
2020-05-31 07:03:01 +02:00
Eric Cousineau
5309573005 operators: Move hash check to before mutations, tweak whitespace 2020-05-31 07:03:01 +02:00
Eric Cousineau
2c30e0a118
cmake: Expose PYBIND11_TEST_OVERRIDE (#2218)
Primarily for the ccmake curses GUI
2020-05-31 07:00:55 +02:00
Andrew J. Hesford
a3118130c6
pytypes.h: fix docs generation (#2220) 2020-05-31 06:59:50 +02:00
Henry Schreiner
a38e5331d7
Fix CI, prepare test on Python 3.9 beta (#2233)
* Test on Python 3.9 beta
* Pin Sphinx
* Newer version of PyPy
2020-05-31 06:29:30 +02:00
Wenzel Jakob
a54eab92d2 Revert "Change __init__(self) to __new__(cls)"
This reverts commit 9ed8b44033.
2020-04-26 22:53:50 +02:00
Dustin Spicuzza
2c4cd8419d Add AutoWIG to list of binding generators (#1990)
* Add AutoWIG to list of binding generators
2020-04-26 18:40:54 +02:00
Nicholas Musolino
02c83dba0f Propagate exceptions in sequence::size() (#2076) 2020-04-26 18:40:52 +02:00
Yannick Jadoul
805c5862b6 Adding method names to cpp_function constructor calls in enum_base 2020-04-26 18:27:18 +02:00
Sebastian Koslowski
a86ac538f5 rename args_kw_only to kwonly 2020-04-26 18:07:51 +02:00
Jason Rhinelander
be0d804523 Support keyword-only arguments
This adds support for a `py::args_kw_only()` annotation that can be
specified between `py::arg` annotations to indicate that any following
arguments are keyword-only.  This allows you to write:

    m.def("f", [](int a, int b) { /* ... */ },
          py::arg("a"), py::args_kw_only(), py::arg("b"));

and have it work like Python 3's:

    def f(a, *, b):
        # ...

with respect to how `a` and `b` arguments are accepted (that is, `a` can
be positional or by keyword; `b` can only be specified by keyword).
2020-04-26 18:07:51 +02:00
peter
03f9e4a8ec Fix compilation with clang-cl 2020-04-26 09:47:34 +02:00
Dustin Spicuzza
0dfffcf257 Add is_final to disallow inheritance from Python
- Not currently supported on PyPy
2020-04-26 09:46:44 +02:00
MRocholl
b14aeb7cfa fix typo in sorted function call argument reverse 2020-04-26 09:29:29 +02:00
MRocholl
9358e30d2a change set_path to set_file 2020-04-26 09:29:29 +02:00
MRocholl
00c462d149 find library path to libclang.so via glob command in /usr/lib/llvm-* and set it 2020-04-26 09:29:29 +02:00
Orell Garten
9ed8b44033 Change __init__(self) to __new__(cls)
__init__(self) cannot return values. According to https://stackoverflow.com/questions/2491819/how-to-return-a-value-from-init-in-python __new__(cls) should be used, which works.
2020-04-26 09:21:42 +02:00
David Stone
5088364b96 Declare operator== and operator!= member functions const. 2020-04-26 09:20:22 +02:00
Axel Huebl
6ebfc4b2b0 Document CMAKE_CXX_STANDARD
This variable is a CMake community standard to set the C++
standard of a build. Document it in favor of the previous variable,
which stays as a legacy flag for existing projects.

https://cmake.org/cmake/help/v3.17/variable/CMAKE_CXX_STANDARD.html
2020-04-26 09:17:10 +02:00
Chuck Atkins
d730fbc0d5 Utilize CMake's language standards abstraction when possible 2020-04-26 09:17:10 +02:00
Ralf W. Grosse-Kunstleve
f6e543b15e Adding a default virtual destructor to Animal type in test_tagbased_polymorphic.cpp.
With this change, and cast.h as-is in master, test_tagbased_polymorphic.cpp fails to compile with the error message below.
With the cast.h change in pull/2016, building and testing succeeds.

cd pybind11/build/tests && /usr/bin/c++  -DPYBIND11_TEST_BOOST -DPYBIND11_TEST_EIGEN -Dpybind11_tests_EXPORTS -Ipybind11/include -I/usr/include/python3.7m -isystem /usr/include/eigen3  -Os -DNDEBUG -fPIC -fvisibility=hidden   -std=c++2a -flto -fno-fat-lto-objects -Wall -Wextra -Wconversion -Wcast-qual -Wdeprecated -o CMakeFiles/pybind11_tests.dir/test_tagbased_polymorphic.cpp.o -c pybind11/tests/test_tagbased_polymorphic.cpp
In file included from pybind11/include/pybind11/attr.h:13,
                 from pybind11/include/pybind11/pybind11.h:44,
                 from pybind11/tests/pybind11_tests.h:2,
                 from pybind11/tests/test_tagbased_polymorphic.cpp:10:
pybind11/include/pybind11/cast.h: In instantiation of ‘static std::pair<const void*, const pybind11::detail::type_info*> pybind11::detail::type_caster_base<type>::src_and_type(const itype*) [with type = Animal; pybind11::detail::type_caster_base<type>::itype = Animal]’:
pybind11/include/pybind11/cast.h:906:31:   required from ‘static pybind11::handle pybind11::detail::type_caster_base<type>::cast_holder(const itype*, const void*) [with type = Animal; pybind11::detail::type_caster_base<type>::itype = Animal]’
pybind11/include/pybind11/cast.h:1566:51:   required from ‘static pybind11::handle pybind11::detail::move_only_holder_caster<type, holder_type>::cast(holder_type&&, pybind11::return_value_policy, pybind11::handle) [with type = Animal; holder_type = std::unique_ptr<Animal>]’
pybind11/include/pybind11/stl.h:175:69:   required from ‘static pybind11::handle pybind11::detail::list_caster<Type, Value>::cast(T&&, pybind11::return_value_policy, pybind11::handle) [with T = std::vector<std::unique_ptr<Animal> >; Type = std::vector<std::unique_ptr<Animal> >; Value = std::unique_ptr<Animal>]’
pybind11/include/pybind11/pybind11.h:159:43:   required from ‘void pybind11::cpp_function::initialize(Func&&, Return (*)(Args ...), const Extra& ...) [with Func = std::vector<std::unique_ptr<Animal> > (*&)(); Return = std::vector<std::unique_ptr<Animal> >; Args = {}; Extra = {pybind11::name, pybind11::scope, pybind11::sibling}]’
pybind11/include/pybind11/pybind11.h:64:9:   required from ‘pybind11::cpp_function::cpp_function(Return (*)(Args ...), const Extra& ...) [with Return = std::vector<std::unique_ptr<Animal> >; Args = {}; Extra = {pybind11::name, pybind11::scope, pybind11::sibling}]’
pybind11/include/pybind11/pybind11.h:819:22:   required from ‘pybind11::module& pybind11::module::def(const char*, Func&&, const Extra& ...) [with Func = std::vector<std::unique_ptr<Animal> > (*)(); Extra = {}]’
pybind11/tests/test_tagbased_polymorphic.cpp:141:36:   required from here
pybind11/include/pybind11/cast.h:880:61: error: ambiguous template instantiation for ‘struct pybind11::polymorphic_type_hook<Animal, void>’
         const void *vsrc = polymorphic_type_hook<itype>::get(src, instance_type);
                            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~
pybind11/include/pybind11/cast.h:844:8: note: candidates are: ‘template<class itype> struct pybind11::polymorphic_type_hook<itype, typename std::enable_if<std::is_polymorphic<_Tp>::value, void>::type> [with itype = Animal]’
 struct polymorphic_type_hook<itype, detail::enable_if_t<std::is_polymorphic<itype>::value>>
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
pybind11/tests/test_tagbased_polymorphic.cpp:115:12: note:                 ‘template<class itype> struct pybind11::polymorphic_type_hook<itype, typename std::enable_if<std::is_base_of<Animal, itype>::value, void>::type> [with itype = Animal]’
     struct polymorphic_type_hook<itype, detail::enable_if_t<std::is_base_of<Animal, itype>::value>>
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from pybind11/include/pybind11/attr.h:13,
                 from pybind11/include/pybind11/pybind11.h:44,
                 from pybind11/tests/pybind11_tests.h:2,
                 from pybind11/tests/test_tagbased_polymorphic.cpp:10:
pybind11/include/pybind11/cast.h:880:61: error: incomplete type ‘pybind11::polymorphic_type_hook<Animal, void>’ used in nested name specifier
         const void *vsrc = polymorphic_type_hook<itype>::get(src, instance_type);
                            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~
2020-04-14 17:48:43 +02:00