Commit Graph

1158 Commits

Author SHA1 Message Date
Ralf W. Grosse-Kunstleve
c30cc404c9 Removing rtti_held from smart_holder. See updated comment. 2021-02-09 06:47:07 -08:00
Ralf W. Grosse-Kunstleve
0f82a0b014 Adding smart_holder_type_caster_load::loaded_as_shared_ptr, currently bypassing smart_holder shared_ptr tracking completely, but the tests pass and are sanitizer clean. 2021-02-09 06:47:07 -08:00
Ralf W. Grosse-Kunstleve
cbebb6da1f Tests for classh py::module_local() feature. 2021-02-09 06:47:07 -08:00
Ralf W. Grosse-Kunstleve
5608b71e09 Removing stray isinstance<T>(src): it interferes with the py::module_local feature. Adding missing #includes. 2021-02-09 06:47:07 -08:00
Ralf W. Grosse-Kunstleve
c362b91a80 Minimal test covering classh_type_casters load_impl Case 2b. 2021-02-09 06:47:07 -08:00
Ralf W. Grosse-Kunstleve
82f619bdb2 Changes and tests covering classh_type_casters try_implicit_casts. 2021-02-09 06:47:06 -08:00
Ralf W. Grosse-Kunstleve
3d4bf091f3 Decoupling generic_type from type_caster_generic. 2021-02-09 06:47:06 -08:00
Ralf W. Grosse-Kunstleve
e345db05bd First pass adjusting try_implicit_casts and try_load_foreign_module_local to capture loaded_v_h, but untested and guarded with pybind11_failure("Untested"). This was done mainly to determine general feasibility. Note the TODO in pybind11.h, where type_caster_generic::local_load is currently hard-coded. test_classh_wip and test_classh_inheritance still pass, as before. 2021-02-09 06:47:06 -08:00
Ralf W. Grosse-Kunstleve
383f7e9b84 Minimal changes needed to pass test_classh_inheritance. 2021-02-09 06:47:06 -08:00
Ralf W. Grosse-Kunstleve
dc537a0013 Folding in modified_type_caster_generic_load_impl, just enough to pass test_class_wip. test_classh_inheritance is still failing, but with a different error: [RuntimeError: Incompatible type (as_raw_ptr_unowned).] 2021-02-09 06:47:06 -08:00
Ralf W. Grosse-Kunstleve
d7efc9b8b1 Adding & using PYBIND11_CLASSH_TYPE_CASTERS define. 2021-02-09 06:47:06 -08:00
Ralf W. Grosse-Kunstleve
1ef19a1e04 Using pybind11/detail/classh_type_casters.h from test_classh_wip.cpp. 2021-02-09 06:47:06 -08:00
Ralf W. Grosse-Kunstleve
29414e6e95 Copying classh type_casters from test_classh_wip.cpp UNMODIFIED, as a baseline for generalizing the code. 2021-02-09 06:47:06 -08:00
Ralf W. Grosse-Kunstleve
2a7d41c193 Moving factored-out make_constructor to test_classh_wip.cpp, restoring previous version of cast.h. This is currently the most practical approach. See PR #2798 for background. 2021-02-09 06:47:06 -08:00
Ralf W. Grosse-Kunstleve
ec86f10038 Using factored-out make_constructor (PR #2798), removing duplicate code. 2021-02-09 06:47:06 -08:00
Ralf W. Grosse-Kunstleve
86ba2081af Removing enable_shared_from_this stub, simplifying existing code, clang-format.
Open question, with respect to the original code:
76a160070b/include/pybind11/pybind11.h (L1510)
To me it looks like the exact situation marked as `std::shared_ptr<Good> gp1 = not_so_good.getptr();` here: https://en.cppreference.com/w/cpp/memory/enable_shared_from_this
The comment there is: `// undefined behavior (until C++17) and std::bad_weak_ptr thrown (since C++17)`
Does the existing code have UB pre C++17?

I'll leave handling of enable_shared_from_this for later, as the need arises.
2021-02-09 06:47:06 -08:00
Ralf W. Grosse-Kunstleve
e4d6d860b6 Fixing bugs discovered by ASAN. The code is now ASAN, MSAN, UBSAN clean. 2021-02-09 06:47:06 -08:00
Ralf W. Grosse-Kunstleve
3bc50c57b4 Bug fix: vptr_deleter_armed_flag_ptr has to live on the heap.
See new bullet point in comment section near the top.

The variable was also renamed to reflect its function more accurately.
2021-02-09 06:47:06 -08:00
Ralf W. Grosse-Kunstleve
6601ec4ea7 static handle cast implementations for rtrn_shmp, rtrn_shcp. 2021-02-09 06:47:05 -08:00
Ralf W. Grosse-Kunstleve
649eb91f21 Adding comment re potential use_count data race. 2021-02-09 06:47:05 -08:00
Ralf W. Grosse-Kunstleve
e7aea026bb Pure clang-format --style=file -i change. 2021-02-09 06:47:05 -08:00
Ralf W. Grosse-Kunstleve
6277910abd Improved error messaging: Cannot disown nullptr (as_unique_ptr). 2021-02-09 06:47:05 -08:00
Ralf W. Grosse-Kunstleve
fe5427fc23 Adding rvalue_ref, renaming const_value_ref to lvalue_ref & removing const. 2021-02-09 06:47:05 -08:00
Ralf W. Grosse-Kunstleve
c8d19f9599 Hard-coding smart_holder into classh. 2021-02-09 06:47:05 -08:00
Ralf W. Grosse-Kunstleve
03f304e419 classh.h: renaming of class_ to classh + namespace; forking test_classh_wip from test_type_caster_bare_interface_demo. 2021-02-09 06:47:05 -08:00
Ralf W. Grosse-Kunstleve
a5818bdf4a Pure copy of class class_ implementation in pybind11.h (master commit 98f1bbb800). 2021-02-09 06:47:05 -08:00
Ralf W. Grosse-Kunstleve
9abea63276 Converting from methods to factory functions (no functional change). 2021-02-09 06:47:04 -08:00
Ralf W. Grosse-Kunstleve
a23e179fee Adding top-level comment. 2021-02-09 06:47:04 -08:00
Ralf W. Grosse-Kunstleve
04a9568487 Implementing all [E]xception tests. 2021-02-09 06:47:04 -08:00
Ralf W. Grosse-Kunstleve
401cdb3b0e Shuffling existing TEST_CASEs into systematic matrix. 2021-02-09 06:47:04 -08:00
Ralf W. Grosse-Kunstleve
bb82add4b0 Adding in vptr_deleter_guard_flag. 2021-02-09 06:47:04 -08:00
Ralf W. Grosse-Kunstleve
5ab34305ae New tests/core/smart_holder_poc_test.cpp, using Catch2. 2021-02-09 06:47:04 -08:00
Ralf W. Grosse-Kunstleve
84bdaebf57 Adding from_shared_ptr. Some polishing. 2021-02-09 06:47:04 -08:00
Ralf W. Grosse-Kunstleve
2a94c687ea Adding from/as unique_ptr<T> and unique_ptr<T, D>. 2021-02-09 06:47:04 -08:00
Ralf W. Grosse-Kunstleve
d1f94e498d Adding vptr_deleter. 2021-02-09 06:47:04 -08:00
Ralf W. Grosse-Kunstleve
72d1b61176 Snapshot of WIP, TODO: shared_ptr deleter with on/off switch 2021-02-09 06:47:04 -08:00
Ralf W. Grosse-Kunstleve
76e7770134 TRIGGER_SEGSEV macro, annotations for GET_STACK (vptr::get), GET_INT_STACK (pointee) 2021-02-09 06:47:04 -08:00
Ralf W. Grosse-Kunstleve
ea1cdf82ce moving prototype code to pybind11/vptr_holder.h, adding type_caster specialization to make the bindings involving unique_ptr passing compile, but load and cast implementations are missing 2021-02-09 06:47:03 -08:00
Karthik Nishanth
e791ec4e27
fix: add null pointer check with std::localtime (#2846) 2021-02-08 15:38:22 -05:00
Yannick Jadoul
6cf6bf203e
Fix confusing weakref constructor overload (#2832)
* Demonstrate issue with weakref constructor overloads

* Fix weakref constructor to convert on being passed a non-weakref object

* Improve on nonlocal-scoped variable in test_weakref

* Keep backwards-compatibility by introducing PYBIND11_OBJECT_CVT_DEFAULT macro

* Simplify test_weakref
2021-01-31 23:13:31 +01:00
Ralf W. Grosse-Kunstleve
932769b038
Adding holder_caster typename SFINAE = void hooks to help work around the current lack of smart-pointer interoperability (#2833)
* Adding move_only_holder_caster `typename SFINAE = void` to enable external specializations.

* Adding SFINAE hook also to copyable_holder_caster, for uniformity, with comment to explain the purpose.
2021-01-30 12:02:24 -08:00
Edward Lockhart
23c3edcf21
When determining if a shared_ptr already exists, use a test on the we… (#2819)
* When determining if a shared_ptr already exists, use a test on the weak_ptr instead of a try/catch block.

* When determining if a shared_ptr already exists, use a test on the weak_ptr instead of a try/catch block.

* weak_from_this is only available in C++17 and later

* Switch to use feature flag instead of C++ version flag.

* Add Microsoft-specific check.

* Avoid undefined preprocessor macro warning treated as error.

* Simplify shared_from_this in init_holder

* Include <version> in detail/common.h (~stolen~ borrowed from @bstaletic's #2816)

* Move class_::get_shared_from_this to detail::try_get_shared_from_this

* Simplify try_get_shared_from_this by using weak_ptr::lock()

Co-authored-by: Yannick Jadoul <yannick.jadoul@belgacom.net>
2021-01-30 20:05:13 +01:00
Ralf W. Grosse-Kunstleve
0432ae7c52
Changing pybind11::str to exclusively hold PyUnicodeObject (#2409)
* Changing pybind11::str to exclusively hold PyUnicodeObject
2021-01-29 09:41:42 -08:00
Yannick Jadoul
587d5f840a
Update breathe to 4.26.1, add make_tuple, make_iterator, and make_key_iterator (#2828) 2021-01-28 12:28:16 +01:00
Ralf W. Grosse-Kunstleve
9b7bfef833
Factoring out find_registered_python_instance() from type_caster_generic::cast. (#2822)
Factoring out find_registered_python_instance() from type_caster_generic::cast.
2021-01-26 21:08:46 -08:00
Henry Fredrick Schreiner
87954e7a54 fix: corrected dev versioning 2021-01-26 22:42:14 -05:00
Henry Fredrick Schreiner
4a5b81b1b7 chore: get back to work 2021-01-26 22:28:09 -05:00
Henry Schreiner
8de7772cc7
chore: prepare for the 2.6.2 release (#2821) 2021-01-26 21:26:45 -05:00
Henry Fredrick Schreiner
732bf88d19 fix: avoid changing class outside of GIL 2021-01-26 20:59:27 -05:00
Yannick Jadoul
0bb8ca2639
Always call PyNumber_Index when casting from Python to a C++ integral type, also pre-3.8 (#2801)
* Always call PyNumber_Index when casting from Python to a C++ integral type, also pre-3.8

* Fixed on PyPy

* Simplify use of PyNumber_Index, following @rwgk's idea, and ignore warnings in >=3.8

* Reproduce mismatch between pre-3.8 and post-3.8 behavior on __index__ throwing TypeError

* Fix tests on 3.6 <= Python < 3.8

* No, I don't have an uninitialized variable

* Fix use of __index__ on Python 2

* Make types in test_int_convert more ~boring~ descriptive
2021-01-25 21:05:17 +01:00