Repository navigation
Conversation
This branch has not been deployed
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.
Summary
jsondiff/jsonpatchcrash with a raw traceback on UTF-8 BOM files (e.g. saved by Windows Notepad).Repro
Expected: prints the patch
[{"op": "replace", "path": "/a", "value": 2}]and exits 1 (documented diff-like contract). Actual before fix:json.decoder.JSONDecodeError: Unexpected UTF-8 BOM (decode using utf-8-sig), exit 1 with traceback. Same forjsonpatchwith BOM inputs.Root cause
jsonpatch_cli.pylines 16, 17 (jsondiff FILE1/FILE2), 54, 56 (jsonpatch ORIGINAL/PATCH): all four CLI inputs useargparse.FileType('"'"'r'"'"', encoding='"'"'utf-8'"'"'), which preserves the BOM as U+FEFF and makesjson.loadraise.utf-8-sigdecodes BOM-less files byte-identically.Fix
encoding='"'"'utf-8'"'"'->encoding='"'"'utf-8-sig'"'"'in the fourargparse.FileTypedeclarations injsonpatch_cli.py. No other code touched.Tests
tests.py::CommandLineTests::test_jsondiff_utf8_bom_files,::test_jsonpatch_utf8_bom_files(existing ScriptRunner + temp-dir unittest style).python -m pytest tests.py -k "utf8_bom or CommandLineTests" -q->27 passed, 1 skipped, 22 subtests passed(skip is pre-existing POSIX-only permissions test).tests.py:336 passed, 1 skipped, plus 1 pre-existing failure inDocumentationTests::test_tutorialthat fails identically on the untouched tree (verified via git stash).--select=E9,F63,F7,F82clean on both touched files.