Repository navigation
v2.5.6: Fix reading gzipped JSONL files with blank lines
·
11 commits
to master
since this release
Backport of the v3.0.1 fixes to the v2.x series.
🔴 Bug fixes
- Fix reading gzipped JSONL files with blank lines (#125).
read_gzip_jsonlreads the file in binary mode, so blank lines arrived asb""and weren't skipped. Instead it raisedValueError: Invalid JSON on line N: b''. This included files written bywrite_gzip_jsonl(..., append=True), which adds a blank separator line, so a srsly write-then-append round trip couldn't be read back. The bug was present sinceread_gzip_jsonlwas added in v2.4.6. - Fix line numbers in JSONL errors. The line number in
Invalid JSON on line Nerrors fromread_jsonlandread_gzip_jsonlnow matches the line in the file. Previously, blank lines and lines skipped as invalid weren't counted. - Show the line text, not a bytes repr, in gzipped JSONL errors. Errors from
read_gzip_jsonlnow show the offending line as text instead ofb'...'. - Fix
json_dumps(data, indent=None), which raisedTypeErrorunlesssort_keys=Truewas also set.indent=Nonenow gives compact output, the same asindent=0.