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).
15 tasks
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.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).