Accept uppercase E exponent after a leading-zero mantissa - #586
Open
eeshsaxena wants to merge 1 commit into
Open
Accept uppercase E exponent after a leading-zero mantissa#586eeshsaxena wants to merge 1 commit into
eeshsaxena wants to merge 1 commit into
Conversation
A float like `0E2` is valid TOML, since both `e` and `E` are allowed exponent markers. The "no leading zeros" guard exempted the mantissa only for lowercase `0e`, so `0E2` (and `0E+2`, `+0E2`, etc.) were rejected as an invalid number while `0e2` parsed fine. Add `0E` to the exempted prefixes.
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.
tomlkitrejects the float0E2, which is valid TOML. BotheandEare allowed exponent markers, andtomlkitalready parses the lowercase form:The signed forms (
+0E2,-0E2,0E+2) fail the same way, andtomllibfrom the standard library accepts all of them. Thevalid/float/exponent-upper.tomlcase in the toml-test suite trips over this on its+0E2line.The cause is the "no leading zeros" guard in
_parse_number: a mantissa beginning with0is exempted only when it is followed by.,o,x,b, or a lowercasee, so0E...falls through to the leading-zero rejection. Adding0Eto the exempted prefixes fixes it. I covered the plain and signed forms intest_parser.py.