Repository navigation
Fix unfinished-escape error positions while preserving EOF diagnostics - #326
Open
Levan-Demetrashvili wants to merge 1 commit into
Open
Levan-Demetrashvili wants to merge 1 commit into
Levan-Demetrashvili wants to merge 1 commit into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #326 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 4 4
Lines 535 535
Branches 100 100
=========================================
Hits 535 535 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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 #312. Related: python/cpython#158566.
An unfinished escape at the end of a basic string or quoted key reports a position one character past EOF. For a document consisting of a quote followed by a backslash,
TOMLDecodeError.posis 3 even though the document has only two characters.Advance by the length of the escape slice actually consumed. The incomplete escape now reports EOF (
pos == len(doc)) and the correct column, while retaining the existing error message. Complete escapes still advance by two characters.This is an alternative to #314, which reports the backslash's position. Reporting EOF follows the convention already used for unterminated strings and preserves the existing
at end of documentmessage.The regression test adds 22 subcases covering quoted and dotted keys, table and array-of-table names, values inside arrays and inline tables, multiline strings, CRLF normalization, Unicode, a final unpaired backslash after an escaped backslash, and both
loads()and binaryload(). It checks the normalized document, position, line, column, and error message. All 22 subcases fail on the unchanged source and pass with the fix.Validation on Linux:
git diff --checkpassed for the relevant source/tests. The complete upstream OS/Python CI matrix has not been run locally.