Commit Graph

2187 Commits

Author SHA1 Message Date
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 b3ad3ac43f Adding unique_ptr<mpty>, unique_ptr<mpty const> casters. 2021-02-09 06:47:05 -08:00
Ralf W. Grosse-Kunstleve d36a7488ae Adding shared_ptr<mpty>, shared_ptr<mpty const> casters. 2021-02-09 06:47:05 -08:00
Ralf W. Grosse-Kunstleve de10541b12 Adding type_caster_bare_interface_demo. 2021-02-09 06:47:05 -08:00
Ralf W. Grosse-Kunstleve 2cb68ab051 Removing stray file. 2021-02-09 06:47:04 -08:00
Ralf W. Grosse-Kunstleve 69270b5dde Removing obsolete and very incomplete test (replaced by Catch2-based test). 2021-02-09 06:47:04 -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 01cacaf207 Testing of exceptions not covered by the from-as matrix. 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 d76050c713 Implementing all [S]uccess 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 1f80387f4b Improved labeling of TEST_CASEs. 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 76e99f1c81 pybind11 equivalent of Boost.Python test similar to reproducer under #1333 2021-02-09 06:47:04 -08:00
Ralf W. Grosse-Kunstleve 8a393e68ab minor test_private_first_base.cpp simplification (after discovering that this can be wrapped with Boost.Python, using boost::noncopyable) 2021-02-09 06:47:04 -08:00
Ralf W. Grosse-Kunstleve 912ce16d0c Demonstration of Undefined Behavior in handling of polymorphic pointers.
(This demo does NOT involve smart pointers at all, unlike the otherwise similar test_smart_ptr_private_first_base.)
2021-02-09 06:47:04 -08:00
Ralf W. Grosse-Kunstleve aac54d4021 fixing up-down mixup in comment 2021-02-09 06:47:04 -08:00
Ralf W. Grosse-Kunstleve 9623045b7b Additional demonstration of Undefined Behavior in handling of shared_ptr holder. 2021-02-09 06:47:04 -08:00
Ralf W. Grosse-Kunstleve bda49efb14 Demonstration of Undefined Behavior in handling of shared_ptr holder.
Based on https://godbolt.org/z/4fdjaW by jorgbrown@ (thanks Jorg!).
2021-02-09 06:47:04 -08:00
Ralf W. Grosse-Kunstleve 96f7ce5444 Copying tests as-is from xxx_value_ptr_xxx_holder branch.
https://github.com/rwgk/pybind11/tree/xxx_value_ptr_xxx_holder

Systematically exercising casting between shared_ptr<base>, shared_ptr<derived>.
2021-02-09 06:47:04 -08:00
Ralf W. Grosse-Kunstleve a923419e6d Copying tests as-is from xxx_value_ptr_xxx_holder branch.
https://github.com/rwgk/pybind11/tree/xxx_value_ptr_xxx_holder

Systematically exercising returning and passing unique_ptr<T>, shared_ptr<T>
with unique_ptr, shared_ptr holder.

Observations:

test_holder_unique_ptr:
  make_unique_pointee  OK
  pass_unique_pointee  BUILD_FAIL (as documented)
  make_shared_pointee  Abort free(): double free detected
  pass_shared_pointee  RuntimeError: Unable to load a custom holder type from a default-holder instance

test_holder_shared_ptr:
  make_unique_pointee  Segmentation fault (#1138)
  pass_unique_pointee  BUILD_FAIL (as documented)
  make_shared_pointee  OK
  pass_shared_pointee  OK
2021-02-09 06:47:04 -08:00
Ralf W. Grosse-Kunstleve 3cf4db18ed adding test_promotion_of_disowned_to_shared 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 4f8447d707 disabling AppVeyor (for this PR) 2021-02-09 06:47:03 -08:00
Ralf W. Grosse-Kunstleve 45a6093c3f disabling GitHub Actions on pull_request (for this PR) 2021-02-09 06:47:03 -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
Ralf W. Grosse-Kunstleve d2c8e3ccde new test_variant_unique_shared with vptr_holder prototype 2021-02-09 06:47:03 -08:00
Ralf W. Grosse-Kunstleve 01e437a2da unique_ptr or shared_ptr return 2021-02-09 06:47:03 -08:00
Ralf W. Grosse-Kunstleve 0a92391128 Adding test_unique_ptr_member (for desired PyCLIF behavior).
See also: https://github.com/pybind/pybind11/issues/2583

Does not build with upstream master or
https://github.com/pybind/pybind11/pull/2047, but builds with
https://github.com/RobotLocomotion/pybind11 and almost runs:

```
Running tests in directory "/usr/local/google/home/rwgk/forked/EricCousineau-TRI/pybind11/tests":
================================================================================= test session starts =================================================================================
platform linux -- Python 3.8.5, pytest-5.4.3, py-1.9.0, pluggy-0.13.1
rootdir: /usr/local/google/home/rwgk/forked/EricCousineau-TRI/pybind11/tests, inifile: pytest.ini
collected 2 items

test_unique_ptr_member.py .F                                                                                                                                                    [100%]

====================================================================================== FAILURES =======================================================================================
_____________________________________________________________________________ test_pointee_and_ptr_owner ______________________________________________________________________________

    def test_pointee_and_ptr_owner():
        obj = m.pointee()
        assert obj.get_int() == 213
        m.ptr_owner(obj)
        with pytest.raises(ValueError) as exc_info:
>           obj.get_int()
E           Failed: DID NOT RAISE <class 'ValueError'>

test_unique_ptr_member.py:17: Failed
============================================================================= 1 failed, 1 passed in 0.06s =============================================================================
```
2021-02-09 06:47:03 -08:00
Axel Huebl c78dfb69f2
MSVC but not Clang: /MP (#2824)
On Windows, clang-cl does not understand /MP.
```
clang-cl: warning: argument unused during compilation: '/MP' [-Wunused-command-line-argument]
```
with Clang 10.0.0
2021-02-08 15:40:04 -05:00
Karthik Nishanth e791ec4e27
fix: add null pointer check with std::localtime (#2846) 2021-02-08 15:38:22 -05:00
Kumar Aditya 948d09d6df
test: Test against Python 3.10 (#2848) 2021-02-08 15:35:30 -05:00
Yannick Jadoul fe845878d1
Make sure all warnings in pytest get turned into errors (#2838)
* Make sure all warnings in pytest get turned into errors

* Suppress DeprecationWarnings in test_int_convert and test_numpy_int_convert

* PyLong_AsLong only shouts "Deprecated!" on Python>=3.8

* Fix remaining warnings on PyPy and CPython 3.10-dev
2021-02-01 14:52:20 +01:00
Henry Schreiner 721834b422
chore: get PyPy 3.7 wheels using NumPy 1.20 (#2837)
* chore: get PyPy 3.7 wheels using NumPy 1.20

* Add Valgrind suppressions after NumPy update

Co-authored-by: Yannick Jadoul <yannick.jadoul@belgacom.net>
2021-01-31 17:29:09 -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