MCPcopy Index your code
hub / github.com/RustPython/RustPython / JSONDecodeError

Class JSONDecodeError

Lib/json/decoder.py:20–57  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

18
19
20class 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 # RUSTPYTHON SPECIFIC
31 @classmethod
32 def _from_serde(cls, msg, doc, line, col):
33 pos = 0
34 # 0-indexed
35 line -= 1
36 col -= 1
37 while line > 0:
38 i = doc.index('\n', pos)
39 line -= 1
40 pos = i
41 pos += col
42 return cls(msg, doc, pos)
43
44 # Note that this exception is used from _json
45 def __init__(self, msg, doc, pos):
46 lineno = doc.count('\n', 0, pos) + 1
47 colno = pos - doc.rfind('\n', 0, pos)
48 errmsg = '%s: line %d column %d (char %d)' % (msg, lineno, colno, pos)
49 ValueError.__init__(self, errmsg)
50 self.msg = msg
51 self.doc = doc
52 self.pos = pos
53 self.lineno = lineno
54 self.colno = colno
55
56 def __reduce__(self):
57 return self.__class__, (self.msg, self.doc, self.pos)
58
59
60_CONSTANTS = {

Callers 7

_decode_uXXXXFunction · 0.85
py_scanstringFunction · 0.85
JSONObjectFunction · 0.85
JSONArrayFunction · 0.85
decodeMethod · 0.85
raw_decodeMethod · 0.85
loadsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected