Fix py::cast from pytype rvalue to pytype (#3949)

* Fix py::cast from pytype rvalue to pytype

Previously, py::cast blindly assumed that the destination type was a C++
type rather than a python type when the source type was an rvalue.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
Maarten Baert
2022-05-16 22:51:01 +02:00
committed by GitHub
parent 48c7be4a56
commit 72eea20afd
3 changed files with 24 additions and 3 deletions

View File

@@ -123,3 +123,10 @@ def test_move_fallback():
assert m1.value == 1
m2 = m.get_moveissue2(2)
assert m2.value == 2
def test_pytype_rvalue_cast():
"""Make sure that cast from pytype rvalue to other pytype works"""
value = m.get_pytype_rvalue_castissue(1.0)
assert value == 1