fix: handle edge cases in peek() and construct_scalar() error handling#923
Open
nightcityblade wants to merge 1 commit intoyaml:mainfrom
Open
fix: handle edge cases in peek() and construct_scalar() error handling#923nightcityblade wants to merge 1 commit intoyaml:mainfrom
nightcityblade wants to merge 1 commit intoyaml:mainfrom
Conversation
- Return '\0' (end-of-stream) from Reader.peek() when the buffer has insufficient data after update, instead of raising IndexError. Fixes yaml#906. - Use getattr() for node.id and node.start_mark in construct_scalar() error path to avoid AttributeError when node is not a Node instance. Fixes yaml#907.
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.
Fixes #906, fixes #907
Changes
Fix IndexError in
Reader.peek()(#906)When the input stream is empty or exhausted,
peek(index)could raise anIndexErrorif the requested index exceeds the buffer length even after callingupdate(). This fix returns'\0'(the end-of-stream sentinel) instead of propagating theIndexError.Fix AttributeError in
construct_scalar()error path (#907)When
construct_scalar()receives an object that is not aNodeinstance, the error-handling code accessednode.idandnode.start_markunconditionally, causing anAttributeError. This fix usesgetattr()with safe fallbacks.Tests
All 1283 existing tests pass: