Commit Graph

1773 Commits

Author SHA1 Message Date
Henry Schreiner
d8c7ee00a6
ci: GHA basic format & pre-commit (#2309) 2020-07-20 13:35:21 -04:00
Kota Yamaguchi
e248869893
Fix undefined memoryview format (#2223)
* Fix undefined memoryview format

* Add missing <algorithm> header

* Add workaround for py27 array compatibility

* Workaround py27 memoryview behavior

* Fix memoryview constructor from buffer_info

* Workaround PyMemoryView_FromMemory availability in py27

* Fix up memoryview tests

* Update memoryview test from buffer to check signedness

* Use static factory method to create memoryview

* Remove ndim arg from memoryview::frombuffer and add tests

* Allow ndim=0 memoryview and documentation fixup

* Use void* to align to frombuffer method signature

* Add const variants of frombuffer and frommemory

* Add memory view section in doc

* Fix docs

* Add test for null buffer

* Workaround py27 nullptr behavior in test

* Rename frombuffer to from_buffer
2020-07-15 08:50:43 -07:00
Boris Staletic
aa982e131d
Small fixes in numpy.h (#2293)
- `PyArray_NewFromDescr_` should have been using `Py_intptr_t const *`
  - 18a6e3e505/numpy/core/src/multiarray/ctors.h (L5-L8)
- `PyArray_GetArrayParamsFromObject_` should be using `NPY_BOOL`
  - 18a6e3e505/numpy/core/src/multiarray/ctors.c (L1350-L1355)
  - https://docs.scipy.org/doc/numpy-1.13.0/reference/c-api.dtype.html#c.npy_bool
- `PyArray_DescrNewFromType` is at offset 96
  - 36e017194c/numpy/core/code_generators/numpy_api.py (L141)
- `array_t` constructor that takes a size and a pointer should take `ssize_t`.
  - Fixes #1599
2020-07-12 16:45:13 +02:00
Florian Apolloner
fe1392d089
Silence Clang 10 compiler warnings. Fixes #2225. (#2294) 2020-07-12 14:16:19 +02:00
Boris Staletic
8b9eb964d9
Check for NULL in raw_str on Python3 (#2290) 2020-07-11 17:20:22 +02:00
Boris Staletic
b2f52225fa
Rename embedded_module object's name (#2282)
This avoids a potential conflict with names in the same scope of the
same name as the embedded module, like namespaces or other global
variables.

Fixes #2172
2020-07-10 16:31:03 +02:00
Yannick Jadoul
964ab956e0
Fix DeprecationWarning about 'invalid escape sequence' in tools/docs Python scripts (#2281) 2020-07-10 16:30:44 +02:00
Yannick Jadoul
f980d76d38
Change NAMESPACE_* macros into PYBIND11_NAMESPACE_* (#2283)
* Change NAMESPACE_BEGIN and NAMESPACE_END macros into PYBIND11_NAMESPACE_BEGIN and PYBIND11_NAMESPACE_END

* Fix sudden HomeBrew 'python not installed' error

* Sweep difference in 'Class.__init__() must be called when overriding __init__' error message between CPython and PyPy under the rug

* Homebrew updated to 3.8 yesterday.

Co-authored-by: Henry Schreiner <HenrySchreinerIII@gmail.com>
2020-07-08 18:14:41 -04:00
Isuru Fernando
0d70f0e18e
PyPy3 support (#2146)
* Error out eval_file

* Enable dynamic attribute support for Pypy >= 6

* Add a test for dynamic attribute support

* Skip test for eval_file on pypy

* Workaround for __qualname__ on PyPy3

* Add a PyPy3.6 7.3.0 build

* Only disable in PyPy3

* Fix travis testing

* No numpy and scipy for pypy

* Enable test on pypy2

* Fix logic in eval_file

* Skip a few tests due to bugs in PyPy

* scipy wheels are broken. make pypy2 a failrue

Co-authored-by: Andreas Kloeckner <inform@tiker.net>
2020-07-07 15:58:16 +02:00
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