Repository navigation
Conversation
run_test_std only treated a completion as a script when it contained the exact string __name__ == "__main__". A program using the equally valid single-quoted form, if __name__ == '__main__':, was exec'd with __name__ bound to builtins, so its entry point never ran, it printed nothing and every stdin test failed even for a correct solution. Match the guard with either quote style and either operand order. Completions without a guard, and double-quoted guards, run exactly as before.
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.
Problem
run_test_stdinllm_evaluation/livecodebench_util.pytreats a completion as a script (it prepends__name__ = "__main__"beforeexec) only when the completion contains the exact string__name__ == "__main__". A program that uses the equally valid single-quoted formis
exec'd with__name__bound tobuiltins, so its entry point never runs, it prints nothing, and every stdin test fails, even when the solution is correct.Reproduction
(
run_test_stdreplacessys.stdout; restore it before printing the result.) With the current code, the single-quoted guard and the reversed form'__main__' == __name__fail; the double-quoted guard and code without a guard pass.Impact
LiveCodeBench rows in
router_inference/predictions/(main, 04c99fd) that were scored 0 and whose last code block uses a single-quoted guard:Open submissions: #229 (BizRouter) has 74 such rows and #228 (dalpha-llm-router) has 7.
To check that these are real solutions and not just a formatting difference, we re-scored the 74 rows of #229 inside the evaluation image with no network: the current code scores all 74 as 0 (reproduced), and with this patch 60 of them pass the tests.
Disclosure: we submitted #229, which is the submission most affected by this bug, because its main model habitually writes the single-quoted guard. The change applies the same rule to every submission; whether and how to re-evaluate existing entries is up to the maintainers.
Fix
Match the guard with either quote style and either operand order (a regex instead of a fixed substring). Completions without a guard, and completions with the double-quoted guard, are executed exactly as before. A guard that can never be true (for example
if __name__ == '__other__':) still does not run.Checked with the pinned pre-commit hooks (ruff v0.11.7, ruff-format, codespell v2.4.1).