diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2012-11-29 00:12:40 +0100 |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2012-11-29 00:12:40 +0100 |
commit | 17b6177b07a5aa233d88ded8dfe919259a6fd22f (patch) | |
tree | a4ea4b3c7c2ee8445a7f24a0639ec48cf134d721 /Lib/json | |
parent | 4560fc27630147bbc6feb30f6c488de65c47d43a (diff) | |
download | cpython-17b6177b07a5aa233d88ded8dfe919259a6fd22f.tar.gz |
Cleanup json decoder: float() has builtin support of nan, +inf, -inf since Python 2.6
Diffstat (limited to 'Lib/json')
-rw-r--r-- | Lib/json/decoder.py | 14 |
1 files changed, 3 insertions, 11 deletions
diff --git a/Lib/json/decoder.py b/Lib/json/decoder.py index 07fd696400..9b7438cd5b 100644 --- a/Lib/json/decoder.py +++ b/Lib/json/decoder.py @@ -1,9 +1,6 @@ """Implementation of JSONDecoder """ -import binascii import re -import sys -import struct from json import scanner try: @@ -15,14 +12,9 @@ __all__ = ['JSONDecoder'] FLAGS = re.VERBOSE | re.MULTILINE | re.DOTALL -def _floatconstants(): - _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() +NaN = float('nan') +PosInf = float('inf') +NegInf = float('-inf') def linecol(doc, pos): |