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 lineno: The line corresponding to pos colno: The column corresponding to pos
| 18 | |
| 19 | |
| 20 | class JSONDecodeError(ValueError): |
| 21 | """Subclass of ValueError with the following additional properties: |
| 22 | |
| 23 | msg: The unformatted error message |
| 24 | doc: The JSON document being parsed |
| 25 | pos: The start index of doc where parsing failed |
| 26 | lineno: The line corresponding to pos |
| 27 | colno: The column corresponding to pos |
| 28 | |
| 29 | """ |
| 30 | # Note that this exception is used from _json |
| 31 | def __init__(self, msg, doc, pos): |
| 32 | lineno = doc.count('\n', 0, pos) + 1 |
| 33 | colno = pos - doc.rfind('\n', 0, pos) |
| 34 | errmsg = '%s: line %d column %d (char %d)' % (msg, lineno, colno, pos) |
| 35 | ValueError.__init__(self, errmsg) |
| 36 | self.msg = msg |
| 37 | self.doc = doc |
| 38 | self.pos = pos |
| 39 | self.lineno = lineno |
| 40 | self.colno = colno |
| 41 | |
| 42 | def __reduce__(self): |
| 43 | return self.__class__, (self.msg, self.doc, self.pos) |
| 44 | |
| 45 | |
| 46 | _CONSTANTS = frozendict({ |
no outgoing calls
no test coverage detected
searching dependent graphs…