Fix LCB grader failing solutions that read sys.stdin.buffer#1257
Open
vineethsaivs wants to merge 1 commit into
Open
Fix LCB grader failing solutions that read sys.stdin.buffer#1257vineethsaivs wants to merge 1 commit into
vineethsaivs wants to merge 1 commit into
Conversation
call_method patched sys.stdin with a StringIO, which has no `buffer` attribute, so solutions doing `sys.stdin.buffer.read()` failed with AttributeError and were graded as incorrect. Expose a binary buffer on the patched stdin (mirroring LiveCodeBench). Adds a regression test. Fixes huggingface#1255 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
What does this PR do?
Fixes #1255.
The LiveCodeBench (LCB) grader's
call_methodpatchessys.stdinwith aStringIO:@patch("sys.stdin", StringIO(inputs))StringIOhas nobufferattribute, so a correct solution that reads binary stdin viasys.stdin.buffer.read()raisesAttributeErrorand is graded as incorrect.Fix
Expose a binary buffer on the patched stdin, mirroring how LiveCodeBench does it:
Test
Added
tests/unit/tasks/test_lcb_codegen_metrics.py::test_call_method_supports_stdin_buffer, which runs a method readingsys.stdin.buffer.read()throughcall_methodand asserts it receives the encoded inputs. The test fails onmain(AttributeError) and passes with this change.Disclosure: prepared with AI assistance; reviewed by me and I can explain every line.