kopia lustrzana https://github.com/micropython/micropython-lib
json: Remove ugly hack to deal with float nan, inf, -inf values.
rodzic
1bc138fcf3
commit
a4833ed354
|
@ -1,9 +1,7 @@
|
||||||
"""Implementation of JSONDecoder
|
"""Implementation of JSONDecoder
|
||||||
"""
|
"""
|
||||||
import binascii
|
|
||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
import struct
|
|
||||||
|
|
||||||
from json import scanner
|
from json import scanner
|
||||||
try:
|
try:
|
||||||
|
@ -15,14 +13,7 @@ __all__ = ['JSONDecoder']
|
||||||
|
|
||||||
FLAGS = re.VERBOSE | re.MULTILINE | re.DOTALL
|
FLAGS = re.VERBOSE | re.MULTILINE | re.DOTALL
|
||||||
|
|
||||||
def _floatconstants():
|
NaN, PosInf, NegInf = float('nan'), float('inf'), float('-inf')
|
||||||
_BYTES = binascii.unhexlify(b'7FF80000000000007FF0000000000000')
|
|
||||||
if sys.byteorder != 'big':
|
|
||||||
_BYTES = _BYTES[:8][::-1] + _BYTES[8:][::-1]
|
|
||||||
nan, inf = struct.unpack('dd', _BYTES)
|
|
||||||
return nan, inf, -inf
|
|
||||||
|
|
||||||
NaN, PosInf, NegInf = _floatconstants()
|
|
||||||
|
|
||||||
|
|
||||||
def linecol(doc, pos):
|
def linecol(doc, pos):
|
||||||
|
|
Ładowanie…
Reference in New Issue