- 01 Jan, 2021 1 commit
-
-
Yannick Jadoul authored
* Fix leak in the test_copy_move::test_move_fallback * Fix leaking PyMethodDef in test_class::test_implicit_conversion_life_support * Plumb leak in test_buffer, occuring when a mutable buffer is requested for a read-only object, and enable test_buffer.py * Fix weird return_value_policy::reference in test_stl_binders, and enable those tests * Cleanup nodelete holder objects in test_smart_ptr, and enable those tests
-
- 16 Dec, 2020 1 commit
-
-
Robert Haschke authored
which was just before set to True in instance->allocate_layout()
-
- 05 Nov, 2020 1 commit
-
-
Boris Staletic authored
-
- 16 Oct, 2020 1 commit
-
-
Yannick Jadoul authored
* Demonstrate test_factory_constructors.py failure without functional changes from #2335 * Revert "Demonstrate test_factory_constructors.py failure without functional changes from #2335" This reverts commit ca33a8021fc2a3617c3356b188796528f4594419. * Fix test crash where registered Python type gets garbage collected * Clean up some more internal structures when class objects go out of scope * Reduce length of std::erase_if-in-C++20 comment * Clean up code for cleaning up type internals * Move cleaning up of type info in internals to tp_dealloc on pybind11_metaclass
-
- 05 Oct, 2020 2 commits
-
-
Yannick Jadoul authored
Fail on passing py::object with wrong Python type to py::object subclass using PYBIND11_OBJECT macro (#2349) * Fail on passing py::object with wrong Python type to py::object subclass using PYBIND11_OBJECT macro * Split off test_non_converting_constructors from test_constructors * Fix test_as_type, as py::type constructor now throws an error itself if the argument is not a type * Replace tp_name access by pybind11::detail::get_fully_qualified_tp_name * Move forward-declaration of get_fully_qualified_tp_name to detail/common.h * Don't add the builtins module name in get_fully_qualified_tp_name for PyPy * Add PYBIND11_BUILTINS_MODULE macro, and use it in get_fully_qualified_tp_name
-
Yannick Jadoul authored
* Remove code inside 'PYPY_VERSION_NUM < 0x06000000' preprocessor if branch * fix: more cleanup * Remove more references to PyPy 5.7 and 5.9 in the docs * Update comment on PyUnicode_UTF* in PyPy Co-authored-by:Henry Schreiner <henryschreineriii@gmail.com>
-
- 03 Oct, 2020 1 commit
-
-
Henry Schreiner authored
* WIP: module -> module_ without typedef * refactor: allow py::module to work again
-
- 02 Oct, 2020 2 commits
-
-
Riyaz Haque authored
* Add tests demonstrating the problem with deregistering pybind11 instances * Fix deregistering of different pybind11 instance from internals Co-authored-by:
Yannick Jadoul <yannick.jadoul@belgacom.net> Co-authored-by:
Blistic <wots_wot@hotmail.com>
-
Yannick Jadoul authored
Moving tp_class access, and consistent fully-qualified naming for PyPy, to detail::get_tp_name (#2520) * Moving tp_class access, and consistent fully-qualified naming for PyPy, to detail::get_tp_name * Change get_tp_name to get_fully_qualified_tp_name
-
- 15 Sep, 2020 1 commit
-
-
Henry Schreiner authored
-
- 14 Aug, 2020 1 commit
-
-
Michael Goulding authored
* Fix warning C26817: Potentially expensive copy of variable 'vh' in range-for loop. Consider making it a const reference (es.71). * Replace another instance of `for (auto vh : values_and_holders(...))` with `auto vh &` (found by @bstaletic) Co-authored-by:
Michael Goulding <Michael.Goulding@microsoft.com> Co-authored-by:
Yannick Jadoul <yannick.jadoul@belgacom.net>
-
- 08 Jul, 2020 1 commit
-
-
Yannick Jadoul authored
* 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>
-
- 07 Jul, 2020 2 commits
-
-
Isuru Fernando authored
* 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>
-
Dustin Spicuzza authored
- Fixes #2103
-
- 26 Apr, 2020 1 commit
-
-
Dustin Spicuzza authored
- Not currently supported on PyPy
-
- 24 Nov, 2019 1 commit
-
-
Sebastian Koslowski authored
-
- 08 Oct, 2019 1 commit
-
-
Sergei Izmailov authored
* Adapt to python3.8 C API change Do `Py_DECREF(type)` on all python objects on deallocation fix #1946 * Add bare python3.8 build to CI matrix While numpy/scipy wheels are available, run python3.8 test without them
-
- 18 Jul, 2019 1 commit
-
-
Jeremy Maitin-Shepard authored
-
- 10 Jun, 2019 2 commits
-
-
Axel Huebl authored
Alternative implementation for #1657: if we know that `obj` is never a `nullptr` [1], we should not `nullptr`-check it *after* already dereferencing it. [1] https://github.com/pybind/pybind11/pull/1657#issuecomment-452090058
-
Steven Johnson authored
Bazel has a "strict" build model that requires all C++ header files be compilable on their own, and thus must explicitly #include all headers they require (even if de facto header inclusion order means they'd get them "for free"). This adds a couple of headers that are needed (but missing) by this model.
-
- 07 Nov, 2017 1 commit
-
-
Jason Rhinelander authored
A few fixes related to how we set `__qualname__` and how we show the type name in function signatures: - `__qualname__` isn't supposed to have the module name at the beginning, but we've been putting it there. This removes it, while keeping the `Nested.Class` name chaining. - print `__module__.__qualname__` rather than `type->tp_name`; the latter doesn't work properly for nested classes, so we would get `module.B` rather than `module.A.B` for a class `B` with parent `A`. This also unifies the Python 3 and PyPy code. Fixes #1166. - This now sets a `__qualname__` attribute on the type (as would happen in Python 3.3+) for Python <3.3, including PyPy. While not particularly important to have in earlier Python versions, it's useful for us to be able to extracted the nested name, which is why `__qualname__` was invented in the first place. - Added tests for the above.
-
- 25 Aug, 2017 1 commit
-
-
Wenzel Jakob authored
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.
-
- 17 Aug, 2017 2 commits
-
-
Jason Rhinelander authored
We currently allocate instance values when creating the instance itself (except when constructing the instance for a `cast()`), but there is no particular reason to do so: the instance itself and the internals (for a non-simple layout) are allocated via Python, with no reason to expect better locality from the invoked `operator new`. Moreover, it makes implementation of factory function constructors trickier and slightly less efficient: they don't use the pre-eallocate the memory, which means there is a pointless allocation and free. This commit makes the allocation lazy: instead of preallocating when creating the instance, the allocation happens when the instance is first loaded (if null at that time). In addition to making it more efficient to deal with cases that don't need preallocation, this also allows for a very slight performance increase by not needing to look up the instances types during allocation. (There is a lookup during the eventual load, of course, but that is happening already).
-
Dean Moldovan authored
-
- 14 Aug, 2017 1 commit
-
-
Jason Rhinelander authored
This adds a PYBIND11_NAMESPACE macro that expands to the `pybind11` namespace with hidden visibility under gcc-type compilers, and otherwise to the plain `pybind11`. This then forces hidden visibility on everything in pybind, solving the visibility issues discussed at end end of #949.
-
- 05 Aug, 2017 1 commit
-
-
Jason Rhinelander authored
Types need `tp_name` set to a C-style string, but the current `strdup` ends up with a leak (issue #977). This avoids the strdup by storing the `std::string` in internals so that during interpreter shutdown it will be properly destroyed.
-
- 29 Jul, 2017 2 commits
-
-
Jason Rhinelander authored
The fix for #960 could result a type being registered multiple times if its `__init__` is called multiple times. This can happen perfectly ordinarily when python-side multiple inheritance is involved: for example, with a diamond inheritance pattern with each intermediate classes invoking the parent constructor. With the change in #960, the multiple `__init__` calls meant `register_instance` was called multiple times, but the deletion only deleted it once. Thus, if a future instance of the same type was allocated at the same location, pybind would pick it up as a registered type. This fixes the issue by tracking whether a value pointer has been registered to avoid both double-registering it. (There's also a slight optimization of not needing to do a registered_instances lookup when the type is known not registered, but this is secondary).
-
Jason Rhinelander authored
The instance registration for offset base types fails (under macOS, with a segfault) in the presense of virtual base types. The issue occurs when trying to `static_cast<Base *>(derived_ptr)` when `derived_ptr` has been allocated (via `operator new`) but not initialized. This commit fixes the issue by moving the addition to `registered_instances` into `init_holder` rather than immediately after value pointer allocation. This also renames it to `init_instance` since it does more than holder initialization now. (I also further renamed `init_holder_helper` to `init_holder` since `init_holder` isn't used anymore). Fixes #959.
-
- 20 Jul, 2017 1 commit
-
-
bennorth authored
To fix a difficult-to-reproduce segfault on Python interpreter exit, ensure that the tp_base field of a handful of new heap-types is counted as a reference to that base type object.
-
- 24 Jun, 2017 1 commit
-
-
Bruce Merry authored
This fixes #856. Instead of the weakref trick, the internals structure holds an unordered_map from PyObject* to a vector of references. To avoid the cost of the unordered_map lookup for objects that don't have any keep_alive patients, a flag is added to each instance to indicate whether there is anything to do.
-
- 12 Jun, 2017 1 commit
-
-
Jason Rhinelander authored
This commit allows multiple inheritance of pybind11 classes from Python, e.g. class MyType(Base1, Base2): def __init__(self): Base1.__init__(self) Base2.__init__(self) where Base1 and Base2 are pybind11-exported classes. This requires collapsing the various builtin base objects (pybind11_object_56, ...) introduced in 2.1 into a single pybind11_object of a fixed size; this fixed size object allocates enough space to contain either a simple object (one base class & small* holder instance), or a pointer to a new allocation that can contain an arbitrary number of base classes and holders, with holder size unrestricted. * "small" here means having a sizeof() of at most 2 pointers, which is enough to fit unique_ptr (sizeof is 1 ptr) and shared_ptr (sizeof is 2 ptrs). To minimize the performance impact, this repurposes `internals::registered_types_py` to store a vector of pybind-registered base types. For direct-use pybind types (e.g. the `PyA` for a C++ `A`) this is simply storing the same thing as before, but now in a vector; for Python-side inherited types, the map lets us avoid having to do a base class traversal as long as we've seen the class before. The change to vector is needed for multiple inheritance: Python types inheriting from multiple registered bases have one entry per base.
-
- 29 May, 2017 1 commit
-
-
Dean Moldovan authored
Fixes #878.
-
- 22 May, 2017 1 commit
-
-
Jason Rhinelander authored
This changes javadoc-style documenting comments from: /** Text starts here * and continues here */ to: /** * Test starts here * and continues here */ which looks a little better, and also matches the javadoc-recommended way of writing documenting comments.
-
- 07 May, 2017 2 commits
-
-
Cris Luengo authored
-
Jason Rhinelander authored
We're current copy by creating an Eigen::Map into the input numpy array, then assigning that to the basic eigen type, effectively having Eigen do the copy. That doesn't work for negative strides, though: Eigen doesn't allow them. This commit makes numpy do the copying instead by allocating the eigen type, then having numpy copy from the input array into a numpy reference into the eigen object's data. This also saves a copy when type conversion is required: numpy can do the conversion on-the-fly as part of the copy. Finally this commit also makes non-reference parameters respect the convert flag, declining the load when called in a noconvert pass with a convertible, but non-array input or an array with the wrong dtype.
-
- 28 Apr, 2017 1 commit
-
-
Jason Rhinelander authored
Python 3's `PyInstanceMethod_Type` hides itself via its `tp_descr_get`, which prevents aliasing methods via `cls.attr("m2") = cls.attr("m1")`: instead the `tp_descr_get` returns a plain function, when called on a class, or a `PyMethod`, when called on an instance. Override that behaviour for pybind11 types with a special bypass for `PyInstanceMethod_Types`.
-
- 27 Apr, 2017 2 commits
-
-
Jason Rhinelander authored
This commits adds base class pointers of offset base classes (i.e. due to multiple inheritance) to `registered_instances` so that if such a pointer is returned we properly recognize it as an existing instance. Without this, returning a base class pointer will cast to the existing instance if the pointer happens to coincide with the instance pointer, but constructs a new instance (quite possibly with a segfault, if ownership is applied) for unequal base class pointers due to multiple inheritance.
-
Jason Rhinelander authored
This breaks up the instance management functions in class_support.h a little bit so that other pybind11 code can use it. In particular: - added make_new_instance() which does what pybind11_object_new does, but also allows instance allocation without `value` allocation. This lets `cast.h` use the same instance allocation rather than having its own separate implementation. - instance registration is now moved to a `register_instance()`/deregister_instance()` pair (rather than having individual code add or remove things from `registered_instances` directory). - clear_instance() does everything `pybind11_object_dealloc()` needs except for the deallocation; this is helpful for factory construction which needs to be able to replace the internals of an instance without deallocating it. - clear_instance() now also calls `dealloc` when `holder_constructed` is true, even if `value` is false. This can happen in factory construction when the pointer is moved from one instance to another, but the holder itself is only copied (i.e. for a shared_ptr holder).
-
- 07 Apr, 2017 1 commit
-
-
Dean Moldovan authored
Fixes #775. Assignments of the form `Type.static_prop = value` should be translated to `Type.static_prop.__set__(value)` except when `isinstance(value, static_prop)`.
-
- 22 Mar, 2017 1 commit
-
-
Dean Moldovan authored
Fixes #754.
-