-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Syntax error points to wrong position in json5 #47
Comments
Yup, that looks like a bug, I'd expect the "f" as well. I'll take a look. |
Looks like this was introduced with the fix for issue #26, which was (partially) attempting to fix a different case where the position was misreported. I'll have to figure out some way to handle both cases ... |
+1 on this one, just cost me some sanity-questioning until I figured out what the parser error was doing. |
Due to the way the parser was handing nested parts of the JSON5 grammar, we would incorrectly report errors as having happened at the start of a block of content, rather than where the error actually happened. A simple case of this would be reporting `"foo"bar` as happening at column 1 rather than column 5. The bug report (#47) has a more complicated and realistic example. To fix this we needed to rev the underlying parser generator (glop) to v0.6.4 and also rewrite the JSON5 grammar to use a positive lookahead.
This is fixed in beb97a9. I've just pushed v0.9.8, which contains this fix, to PyPI. Sorry this took so long for a fix, there were $REASONS why I wasn't on top of this, plus once I started looking at it, the bug ended up being a rather subtle problem in the generated parsing code (i.e., in the parser generator). |
When there is an error in a json5 file, the error message seems to always point to the first element in the json5 file.
For example:
Gives the error:
I would expect the error:
ValueError: <string>:7 Unexpected "f" at column 16.
json5 version: 0.9.6
OS: Windows 10
Python: 3.8.8
The text was updated successfully, but these errors were encountered: