Repository navigation
Conversation
The initial_value argument was converted by the argument clinic before
the body ran, so a non-str initial_value raised TypeError even when
newline was invalid. CPython checks newline first and raises
ValueError("illegal newline value: ...") in that case. Convert
initial_value after the newline check.
Signed-off-by: Jeongseop Lim <jeongseop_lim@korea.ac.kr>
This branch has not been deployed
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.
Description
Fixes #1257
io.StringIO()convertedinitial_valuethrough an Argument ClinicTStringconversion, which ran beforenewlinewas validated, so a call with both arguments invalid raisedTypeErrorforinitial_valueinstead ofValueErrorfornewline. CPython's_io_StringIO___init___implchecksnewlinefirst andinitial_valuelast (stringio.c#L670-L698).AS-IS
TO-BE
(exception classes matching CPython; the
newlinemessage wording was already different on master)Changes
initial_valuefromStringIOBuiltins.InitNodeand convert it withCastToTruffleStringNodeaftervalidateNewline, treatingNoneand a missing argument as the empty string.ErrorMessages.INITIAL_VALUE_MUST_BE_STR_OR_NONE_NOT_Pfor a non-strinitial_value.test_stringio_validates_newline_before_initial_valuetotests/test_io.py.Testing
mx python-jvmon darwin-aarch64, thenmx graalpytest test_io.py(29 passed, 1 skipped).test.test_memoryio(161 passed) andtest.test_univnewlines(34 passed) fromlib-pythonpass. The new test fails on the unpatched build. FourteenStringIO()argument combinations now raise the same exception classes as CPython 3.13.14.