Whole file
simplejson/simplejson
The author described this change as “SJ-PT-23-100: Fix inconsistencies in error messages between C and Python implementations”. It counts as a record because the check below fails on the code as it stood at 59dac4e82 and passes on dbd0aa395, with nothing else changed between the two runs.
Projectsimplejson/simplejson
Fix saved2023-04-04
Sharing licenceMIT · LICENSE.txt
Change size+3 −2
What the code was meant to do, written into the code itself as a save note
SJ-PT-23-100: Fix inconsistencies in error messages between C and Python implementations
The change
| 93 | 93 | if chunk is None: | |
| 94 | 94 | raise JSONDecodeError( | |
| 95 | 95 | "Unterminated string starting at", s, begin) | |
| 96 | + | prev_end = end | |
| 96 | 97 | end = chunk.end() | |
| 97 | 98 | content, terminator = chunk.groups() | |
| 98 | 99 | # Content is contains zero or more unescaped string characters | |
| ⋯ | |||
| 107 | 108 | elif terminator != '\\': | |
| 108 | 109 | if strict: | |
| 109 | 110 | msg = "Invalid control character %r at" | |
| 110 | - | raise JSONDecodeError(msg, s, end) | |
| 111 | + | raise JSONDecodeError(msg, s, prev_end) | |
| 111 | 112 | else: | |
| 112 | 113 | _append(terminator) | |
| 113 | 114 | continue | |
| ⋯ | |||
| 178 | 179 | return pairs, end + 1 | |
| 179 | 180 | elif nextchar != '"': | |
| 180 | 181 | raise JSONDecodeError( | |
| 181 | - | "Expecting property name enclosed in double quotes", | |
| 182 | + | "Expecting property name enclosed in double quotes or '}'", | |
| 182 | 183 | s, end) | |
| 183 | 184 | end += 1 | |
| 184 | 185 | while True: | |
The check that tells the two apart
fail→pass·simplejson/tests/test_fail.py::TestFail::test_truncated_input
Check file simplejson/tests/test_fail.py, taken without changes from the fix and copied onto the older code, so the exact same check runs against both versions.
Origin and history
The code before it59dac4e82cd6766fc31a9389d573d732580eaab5
Broken version dated2023-04-04
Modulesimplejson.decoder
Units changedJSONObject, py_scanstring
Fingerprintb157ba4fd93198eb
Checked2026-08-18 by goldset/0.1
Every field above is generated by our program. None of it is written by hand.
Other bugs found in simplejson/simplejson
- 2013-10-05JSONDecodeError