Skip to content

fix: support implicit value conversions in native trampolines - #6204

Open
CAOShurong wants to merge 3 commits into
pybind:masterfrom
CAOShurong:codex/fix-implicit-trampoline-value-return
Open

CAOShurong wants to merge 3 commits into
pybind:masterfrom
CAOShurong:codex/fix-implicit-trampoline-value-return

Conversation

@CAOShurong

Copy link
Copy Markdown

Description

Fixes #6080.

When native C++ calls a Python override, an implicit conversion of the returned list to an opaque vector can fail because no loader frame is active. Keep conversion temporaries alive until the registered return value has been copied or moved out. Reuse an existing frame, and leave borrowed reference, pointer, and view returns unchanged.

The embedded-interpreter regression covers retained and temporary Python lists, shared ownership, temporary destruction, and rejection of borrowed results that would outlive a conversion frame. It fails on current master and passes with the fix.

Validation on Windows/MSVC and Python 3.13: all embedded C++ tests, eight CMake integration checks, packaging tests, and installed C++14 consumers in header-only and precompiled modes passed. The full Python suite had 1,311 passes, 53 skips, and eight chrono failures also reproduced on unchanged master. Debug builds with warnings as errors passed; Release builds hit C4702 on both master and this branch.

Suggested changelog entry:

  • Fix implicit conversions of registered value returns from Python overrides called by native C++.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG]: cast_error using PYBIND11_OVERRIDE with implicitly converted opaque vectors

1 participant