LocalPythonExecutor: bind keyword-only and positional-only parameters #3170
All Vouch review confidence checks passed
Residual risk 0.19 = Change Risk (0.45) × (1 − Review Confidence (0.57)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.45 · 410 lines diff across 5 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.360
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #3170"
general
weight: 0.35
its-amann
LocalPythonExecutornever looks atkwonlyargs/posonlyargswhen it builds a function's frame, so an ordinary signature silently turns into an undefined variable.Fixes #3161
Same line of code, two more things that fall over (from #3165):
and the
except ... as nametarget stays bound inexecutor.stateafter the handler is done:What changed
create_function:(posonlyargs, args). They sit first in the signature, so/parameters bind the same way as the rest.kw_defaultsand merged into the samedefaultsdict.kw_defaultskeeps aNoneplaceholder for parameters that have no default (def f(, a, b=1)), those are skipped, same as CPython.create_functionitself, instead of on every call. They are still evaluated with the defining scope asstate, so a default that closes over a name keeps working, butdef f(, value=allocate())now allocates once instead of once per call (and an explicitf(value=99)doesn't evaluate it at all, which it used to). The positional side had the same problem, so both are captured at definition time.kwargs:def f(a, /, kw)called asf(1, a=2)is(1, {'a': 2}), not(2, {'a': 2}).evaluate_try:try/finally, and thefinallypops the handler name fromstate. That's what makesdel caughthappen on a normal exit, areturnout of the handler, or an exception thrown from the handler. The exception object is what keeps its traceback (and every frame in it) alive, so dropping the name also stops the executor from holding onto a whole traceback for the rest of the run.except Xwithoutasis untouched, and so is the re-raise path when no handler matches.Tests
Added to
tests/test_local_python_executor.py:test_keyword_only_default_arg_in_functiontest_positional_only_arg_in_functiontest_positional_only_name_passed_by_keyword_goes_to_kwargstest_default_values_are_evaluated_once_at_definitiontest_exception_target_is_unbound_after_the_handler(also checks the name shadows an outer variable only inside the handler)test_exception_target_is_unbound_when_the_handler_raisesAll six fail on
96f33fawithout the source change, all six pass with it.The 3 remaining failures are environment ones and fail identically on
96f33fa(sklearnnot installed; two pandas chained-comparison cases that depend on the pandas version). I diffed the failing test list of the wider suite before and after (64 failed / 864 passedvs68 failed / 858 passed), the only difference is the tests added here flipping to green.