Show More
@@ -11,6 +11,7 b'' | |||||
11 | # Imports |
|
11 | # Imports | |
12 | #----------------------------------------------------------------------------- |
|
12 | #----------------------------------------------------------------------------- | |
13 | # stdlib |
|
13 | # stdlib | |
|
14 | import math | |||
14 | import re |
|
15 | import re | |
15 | import sys |
|
16 | import sys | |
16 | import types |
|
17 | import types | |
@@ -30,12 +31,6 b" next_attr_name = '__next__' if py3compat.PY3 else 'next'" | |||||
30 | ISO8601="%Y-%m-%dT%H:%M:%S.%f" |
|
31 | ISO8601="%Y-%m-%dT%H:%M:%S.%f" | |
31 | ISO8601_PAT=re.compile(r"^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d+$") |
|
32 | ISO8601_PAT=re.compile(r"^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d+$") | |
32 |
|
33 | |||
33 | # float constants |
|
|||
34 | NAN = float('nan') |
|
|||
35 | INF = float('inf') |
|
|||
36 | NINF = float('-inf') |
|
|||
37 | INFS = (INF, NINF) |
|
|||
38 |
|
||||
39 | #----------------------------------------------------------------------------- |
|
34 | #----------------------------------------------------------------------------- | |
40 | # Classes and functions |
|
35 | # Classes and functions | |
41 | #----------------------------------------------------------------------------- |
|
36 | #----------------------------------------------------------------------------- | |
@@ -174,7 +169,7 b' def json_clean(obj):' | |||||
174 |
|
169 | |||
175 | if isinstance(obj, float): |
|
170 | if isinstance(obj, float): | |
176 | # cast out-of-range floats to their reprs |
|
171 | # cast out-of-range floats to their reprs | |
177 | if obj != obj or obj in INFS: |
|
172 | if math.isnan(obj) or math.isinf(obj): | |
178 | return repr(obj) |
|
173 | return repr(obj) | |
179 | return obj |
|
174 | return obj | |
180 |
|
175 |
General Comments 0
You need to be logged in to leave comments.
Login now