1 """Error classes used by simplejson
3 __all__ = [
'JSONDecodeError']
7 lineno = doc.count(
'\n', 0, pos) + 1
11 colno = pos - doc.rindex(
'\n', 0, pos)
16 lineno, colno =
linecol(doc, pos)
17 msg = msg.replace(
'%r', repr(doc[pos:pos + 1]))
19 fmt =
'%s: line %d column %d (char %d)'
20 return fmt % (msg, lineno, colno, pos)
21 endlineno, endcolno =
linecol(doc, end)
22 fmt =
'%s: line %d column %d - line %d column %d (char %d - %d)'
23 return fmt % (msg, lineno, colno, endlineno, endcolno, pos, end)
27 """Subclass of ValueError with the following additional properties:
29 msg: The unformatted error message
30 doc: The JSON document being parsed
31 pos: The start index of doc where parsing failed
32 end: The end index of doc where parsing failed (may be None)
33 lineno: The line corresponding to pos
34 colno: The column corresponding to pos
35 endlineno: The line corresponding to end (may be None)
36 endcolno: The column corresponding to end (may be None)
42 ValueError.__init__(self,
errmsg(msg, doc, pos, end=end))
51 self.endlineno, self.
endcolno =
None,
None
54 return self.__class__, (self.
msg, self.
doc, self.
pos, self.
end)