Conversation
ctypes function objects built without paramflags only bind arguments positionally, but functools.wraps copies each def's type-hinted signature onto them anyway, so the public signature looks keyword-friendly even though calling by keyword either raises a confusing TypeError or silently drops an argument at the ctypes layer. Every other ctypes_function binding in this file already guards against this with a trailing `/`. llama_sampler_init_dist, _top_k, _top_p, _min_p, _typical, _temp, and _temp_ext were missed; this was the only class of binding in the file without it. Closes abetlen#2371
Covers the seven bindings fixed for abetlen#2371: each gets a test confirming a keyword call that's short on positional arguments is rejected outright with TypeError. Also adds one test documenting a related but unfixed case: once every positional slot is already filled, ctypes silently ignores an extra keyword instead of raising. Positional-only marking can't close that, since there's no unfilled slot left for it to protect.
This branch has not been deployed
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.
Fixes #2371.
ctypes function objects built without paramflags only bind arguments positionally, but
functools.wrapscopies eachdef's type-hinted signature onto them anyway, so a keyword call type-checks fine but either raises a confusingTypeErroror silently drops an argument at runtime.llama_sampler_init_dist,_top_k,_top_p,_min_p,_typical,_temp, and_temp_extpositional-only with a trailing/, matching every other binding inllama_cpp.py.@ctypes_functionbindings in the file; these seven were the only ones missing it.