-
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
Pretty formatting puts commas inside empty arrays or objects #26
Comments
Also looks like these strings won't round-trip through the parser:
|
Thanks for the report. The '[\n ,\n]' is definitely a bug. The fact that the strings won't round-trip is not a bug, because the input string isn't legal :) That fact that the error message is reporting the wrong unexpected character, however, is a bug :). These should be easy fixes, I'll try to get to them today. |
This addresses #26: `json5.dumps([], indent=2)` incorrectly returned '[\n ,\n]', when it should've returned '[]' (and the did the same thing for objects).
This patch addresses an error reported in #26, where calling `json.loads('[ ,]') would report an error on column 4, not column 3. The reason for this had to do with the way the optional whitespace (sp*) rule was coded in the grammar, and a bug in the underlying parser generator (glop), where if you had a rule like (a ?())* and you matched a and not b, the errposition wouldn't be properly rolled back before the conditional expression. That bug was fixed in glop v0.6.2; this CL regenerates the JSON5 parser with that version of the parser generator, and then adds json5-specific tests to check for the correct position reporting.
Fixed in 6c4038e (v0.8.5). This actually required a fix to the underlying parser generator (glop, v0.6.2) to fix the error reporting, so double-bonus bug report :). |
This modifies the fix in f259ff, which wasn't quite right. We were incorrectly rolling back the `errpos` field when rules failed, which would lead to errors being reported as having happened at the beginning of a rule, rather than at the spot where something actually happened. In debugging this, I realized that part of the problem is that error reporting for semantic predicate failures doesn't quite work right, so I've filed a new bug for that and updated the tests to be clearer. See dpranke/pyjson5#26 and #3 for more on this.
The stock
json
module doesn't do this. Repro:The text was updated successfully, but these errors were encountered: