mirror of
https://github.com/pybind/pybind11.git
synced 2025-02-27 08:04:56 +00:00
* git merge --squash purge_internals_versions_4_5
* Remove PYBIND11_HAS_INTERNALS_WITH_SMART_HOLDER_SUPPORT, set PYBIND11_INTERNALS_VERSION 7
* Remove all uses of PYBIND11_SMART_HOLDER_ENABLED under include/pybind11
* Remove obsolete PYBIND11_ACTUALLY_USING_SMART_HOLDER_AS_DEFAULT macro.
* Remove PYBIND11_SMART_HOLDER_ENABLED in ubench/holder_comparison.cpp
* Remove all uses of PYBIND11_SMART_HOLDER_ENABLED under tests/
* Remove `#define PYBIND11_SMART_HOLDER_ENABLED`
* Remove all uses of PYBIND11_SMART_HOLDER_TYPE_CASTERS under tests/
* Remove all uses of PYBIND11_TYPE_CASTER_BASE_HOLDER under tests/
* Add missing `#include <cstdint>`
Example error message (🐍 3.11 • ubuntu-latest • x64, GNU 13.3.0):
```
include/pybind11/detail/value_and_holder.h:56:52: error: ‘uint8_t’ is not a member of ‘std’; did you mean ‘wint_t’?
56 | inst->nonsimple.status[index] &= (std::uint8_t) ~instance::status_holder_constructed;
| ^~~~~~~
```
* Change PYBIND11_INTERNALS_VERSION to 106: It will be changed to 7 in a follow-on PR that actually changes the internals.
54 lines
1.5 KiB
Python
54 lines
1.5 KiB
Python
from __future__ import annotations
|
|
|
|
import pytest
|
|
|
|
from pybind11_tests import class_sh_mi_thunks as m
|
|
|
|
|
|
def test_ptrdiff_drvd_base0():
|
|
ptrdiff = m.ptrdiff_drvd_base0()
|
|
# A failure here does not (necessarily) mean that there is a bug, but that
|
|
# test_class_sh_mi_thunks is not exercising what it is supposed to.
|
|
# If this ever fails on some platforms: use pytest.skip()
|
|
# If this ever fails on all platforms: don't know, seems extremely unlikely.
|
|
assert ptrdiff != 0
|
|
|
|
|
|
@pytest.mark.parametrize(
|
|
"vec_size_fn",
|
|
[
|
|
m.vec_size_base0_raw_ptr,
|
|
m.vec_size_base0_shared_ptr,
|
|
],
|
|
)
|
|
@pytest.mark.parametrize(
|
|
"get_fn",
|
|
[
|
|
m.get_drvd_as_base0_raw_ptr,
|
|
m.get_drvd_as_base0_shared_ptr,
|
|
m.get_drvd_as_base0_unique_ptr,
|
|
],
|
|
)
|
|
def test_get_vec_size_raw_shared(get_fn, vec_size_fn):
|
|
obj = get_fn()
|
|
assert vec_size_fn(obj) == 5
|
|
|
|
|
|
@pytest.mark.parametrize(
|
|
"get_fn", [m.get_drvd_as_base0_raw_ptr, m.get_drvd_as_base0_unique_ptr]
|
|
)
|
|
def test_get_vec_size_unique(get_fn):
|
|
obj = get_fn()
|
|
assert m.vec_size_base0_unique_ptr(obj) == 5
|
|
with pytest.raises(ValueError, match="Python instance was disowned"):
|
|
m.vec_size_base0_unique_ptr(obj)
|
|
|
|
|
|
def test_get_shared_vec_size_unique():
|
|
obj = m.get_drvd_as_base0_shared_ptr()
|
|
with pytest.raises(ValueError) as exc_info:
|
|
m.vec_size_base0_unique_ptr(obj)
|
|
assert (
|
|
str(exc_info.value) == "Cannot disown external shared_ptr (load_as_unique_ptr)."
|
|
)
|