This issue tracker has been migrated to GitHub ,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2013年10月23日 11:22 by musically_ut, last changed 2022年04月11日 14:57 by admin. This issue is now closed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| json_JSONDecodeError.patch | serhiy.storchaka, 2014年10月05日 10:16 | review | ||
| json_JSONDecodeError_2.patch | serhiy.storchaka, 2014年11月30日 22:20 | review | ||
| Messages (9) | |||
|---|---|---|---|
| msg201015 - (view) | Author: Utkarsh Upadhyay (musically_ut) * | Date: 2013年10月23日 11:22 | |
The JSON parser currently throws exceptions which contain information about where the error happened but this information is encoded in a string and not available to the programmer. This leads to issues like this: http://stackoverflow.com/questions/19519409/how-to-get-error-location-from-json-loads-in-python Would it be a problem if the errors thrown were specialized exceptions, e.g. JSONParsingError, which has ValueError as a base class with these details (line number, char number, etc.) exposed as public members? The changes required seem to be limited to changing http://hg.python.org/cpython/file/4c4f31a1b706/Lib/json/decoder.py and the related documentation. |
|||
| msg201025 - (view) | Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) | Date: 2013年10月23日 13:56 | |
Simplejson already have JSONDecodeError. class JSONDecodeError(ValueError): """Subclass of ValueError with the following additional properties: msg: The unformatted error message doc: The JSON document being parsed pos: The start index of doc where parsing failed end: The end index of doc where parsing failed (may be None) lineno: The line corresponding to pos colno: The column corresponding to pos endlineno: The line corresponding to end (may be None) endcolno: The column corresponding to end (may be None) """ Adding it to the stdlib is only matter of time. |
|||
| msg201028 - (view) | Author: Utkarsh Upadhyay (musically_ut) * | Date: 2013年10月23日 14:06 | |
Excellent! Is there an issue for merging Simplejson into stdlib? If so, can this issue be linked to that issue? |
|||
| msg218930 - (view) | Author: Raymond Hettinger (rhettinger) * (Python committer) | Date: 2014年05月22日 22:58 | |
> Adding it to the stdlib is only matter of time. I think we can go forward with it right now. |
|||
| msg218935 - (view) | Author: Bob Ippolito (bob.ippolito) * (Python committer) | Date: 2014年05月22日 23:20 | |
simplejson v3.5.1 is probably a good target, let me know if there's anything that you'd like me to merge back in from stdlib to make maintenance easier. I haven't been tracking stdlib except when I've been added to issues. |
|||
| msg228555 - (view) | Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) | Date: 2014年10月05日 10:15 | |
Here is a patch which adopts JSONDecodeError from simplejson. Unlike to simplejson it is located in the json.decoder module (json uses different way to pass an error from scanner to decoder). |
|||
| msg231501 - (view) | Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) | Date: 2014年11月21日 21:17 | |
While we here may be change error messages? The only error which contains end position is "Extra data". And it doesn't look clean to me why end position should be mentioned at all (it is always len(data) here). I suggest to drop it, this will make error message cleaner and JSONDecodeError simpler. May be mention line and column in error message only if JSON data is multiline? Most machine generated data has one line only. Instead of "Expecting ',' delimiter: line 1 column 123 (char 124)" I suggest "Expecting ',' delimiter at position 124". Same as in re.error. |
|||
| msg231907 - (view) | Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) | Date: 2014年11月30日 22:20 | |
Updated patch provides JSONDecodeError without end* attributes and with changed message for "Extra data". |
|||
| msg234734 - (view) | Author: Roundup Robot (python-dev) (Python triager) | Date: 2015年01月26日 11:17 | |
New changeset 07af9847dbec by Serhiy Storchaka in branch 'default': Issue #19361: JSON decoder now raises JSONDecodeError instead of ValueError. https://hg.python.org/cpython/rev/07af9847dbec |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:57:52 | admin | set | github: 63560 |
| 2015年01月26日 11:17:42 | python-dev | set | nosy:
+ python-dev messages: + msg234734 |
| 2015年01月26日 11:17:41 | serhiy.storchaka | set | status: open -> closed resolution: fixed stage: patch review -> resolved |
| 2014年12月02日 17:04:35 | Arfrever | set | nosy:
+ Arfrever |
| 2014年11月30日 22:20:31 | serhiy.storchaka | set | files:
+ json_JSONDecodeError_2.patch messages: + msg231907 |
| 2014年11月21日 21:17:59 | serhiy.storchaka | set | messages: + msg231501 |
| 2014年10月05日 10:16:33 | serhiy.storchaka | set | files:
+ json_JSONDecodeError.patch keywords: + patch |
| 2014年10月05日 10:15:47 | serhiy.storchaka | set | versions:
+ Python 3.5, - Python 3.4 messages: + msg228555 assignee: serhiy.storchaka keywords: + needs review stage: patch review |
| 2014年05月22日 23:20:37 | bob.ippolito | set | messages: + msg218935 |
| 2014年05月22日 22:58:39 | rhettinger | set | nosy:
+ bob.ippolito messages: + msg218930 |
| 2014年05月16日 04:32:14 | cvrebert | set | nosy:
+ cvrebert |
| 2013年10月23日 14:06:43 | musically_ut | set | messages: + msg201028 |
| 2013年10月23日 13:56:31 | serhiy.storchaka | set | nosy:
+ serhiy.storchaka messages: + msg201025 |
| 2013年10月23日 11:25:09 | ezio.melotti | set | nosy:
+ rhettinger, pitrou, ezio.melotti components: + Library (Lib) versions: + Python 3.4 |
| 2013年10月23日 11:22:14 | musically_ut | create | |