fix: correct args_convert flags for kw-only args after py::args - #6160
Open
henryiii wants to merge 1 commit into
Open
fix: correct args_convert flags for kw-only args after py::args#6160henryiii wants to merge 1 commit into
henryiii wants to merge 1 commit into
Conversation
The `*args` stub was pushed into `call.args` in step 2, but its convert
flag was appended after all of the keyword-only flags in step 4a. Each
keyword-only argument thus received the flag of its successor, so
`py::arg("x").noconvert()` applied to the wrong argument. Push the flag
together with the stub, and append it in step 4a only when the tuple
itself is appended.
The second-pass scan also stopped at `pos_args`, so an overload whose
only convertible arguments are keyword-only never got a converting pass.
Scan all of the flags instead.
Fixes items 1 and 2 of pybind#6159.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🤖 AI text below 🤖
Description
Two related problems in the function dispatcher, items 1 and 2 of #6159.
When named arguments follow
py::args, the dispatcher pushes a stub for the*argstuple intocall.argsin step 2, but appended its convert flag at the end in step 4a. Each keyword-only argument thus got the convert flag of the next argument, sopy::arg("x").noconvert()applied to the wrong argument. The flag is now pushed together with the stub, and step 4a appends a flag only when it appends the tuple itself.The second-pass scan stopped at
pos_args. An overload whose only convertible arguments are keyword-only was thus never retried with conversion permitted. The scan now examines all of the flags.Both problems have new tests in
tests/test_kwargs_and_defaults.Suggested changelog entry:
noconvertflags and the overload second pass for keyword-only arguments that followpy::args.