Repository navigation
Conversation
run_test_std replaced sys.stdin with a StringIO, which has no .buffer attribute. A solution that reads its input through sys.stdin.buffer, the common fast-input idiom (data = sys.stdin.buffer.read().split()), raised AttributeError before printing anything, so every stdin test failed even when the solution was correct. Use a text stream over a bytes buffer instead. input(), sys.stdin.read, sys.stdin.readline and line iteration behave as before (newline="\n" keeps StringIO's newline handling), and sys.stdin.buffer now reads the test input. LiveCodeBench's own harness also gives stdin a buffer (MockStdinWithBuffer in lcb_runner/evaluation/testing_util.py).
|
Correction to the row counts in "Impact" The counts in the Impact section included
None of these rows passes with the current code. Open submissions: #228 (dalpha-llm-router) has 30 scored rows, 28 of which pass with this patch; its other 12 rows (all passing) are The bug, the fix and the regression check are unchanged. |
Problem
run_test_stdinllm_evaluation/livecodebench_util.pyreplacessys.stdinwithStringIO(test_input). AStringIOhas nobufferattribute, so a solution that reads its input throughsys.stdin.buffer(the common fast-input idiomdata = sys.stdin.buffer.read().split()) raisesAttributeErrorbefore printing anything, and every stdin test fails even when the solution is correct. The failure is recorded as an ordinary wrong answer, so it does not stand out.LiveCodeBench's own harness handles this case: since LiveCodeBench/LiveCodeBench@16de2a1 (May 2025),
lcb_runner/evaluation/testing_util.pyreplaces stdin with a mock that has abufferattribute (MockStdinWithBuffer).Reproduction
(
run_test_stdreplacessys.stdout; restore it before printing the result.)sys.stdin.buffer.readline()fails the same way.input(),sys.stdin.read(),sys.stdin.readline()andfor line in sys.stdinpass before and after the change.Impact
LiveCodeBench stdin rows whose last code block reads
sys.stdin.buffer, re-scored inside the evaluation image with no network, with the current code and with this patch:Open submissions: #228 (dalpha-llm-router) has 42 such rows (0 pass now, 40 with this patch), #232 (divyam-router) has 34 (0 now, 30 with this patch), and #229 (BizRouter) has none.
Regression check: every LiveCodeBench stdin row of KT-ModelRouter (202 rows, none of which reads
sys.stdin.buffer) scores the same with and without the patch (178 pass in both), and no row that passes with the current code fails with the patch.Disclosure: we submitted #229 and #230. #229 has no rows that read
sys.stdin.buffer, so this change does not affect its score; it raises the scores of other submissions, including open ones. We found the bug while evaluating a model that reads stdin this way in most of its stdin answers. As with #230, whether and how to re-evaluate existing entries is up to the maintainers.Fix
Give
run_test_stda text stream over a bytes buffer (io.TextIOWrapper(io.BytesIO(...), encoding="utf-8", newline="\n")) instead of aStringIO. Text reads behave as before (newline="\n"keepsStringIO's newline handling), andsys.stdin.bufferreads the same input.This is independent of #230: the two changes touch different lines of
run_test_stdand merge cleanly in either order.Checked with the pinned pre-commit hooks (ruff v0.11.7, ruff-format, codespell v2.4.1, mypy).