mirror of
https://github.com/python/cpython.git
synced 2025-12-23 09:19:18 +00:00
Merge 528fe30c38 into a273bc99d2
This commit is contained in:
commit
17fce22b4f
1 changed files with 6 additions and 3 deletions
|
|
@ -179,6 +179,11 @@ class JSONEncoder(object):
|
|||
return super().default(o)
|
||||
|
||||
"""
|
||||
if isinstance(o, float):
|
||||
raise ValueError(
|
||||
"Out of range float values are not JSON compliant: " +
|
||||
repr(o)
|
||||
)
|
||||
raise TypeError(f'Object of type {o.__class__.__name__} '
|
||||
f'is not JSON serializable')
|
||||
|
||||
|
|
@ -239,9 +244,7 @@ class JSONEncoder(object):
|
|||
return _repr(o)
|
||||
|
||||
if not allow_nan:
|
||||
raise ValueError(
|
||||
"Out of range float values are not JSON compliant: " +
|
||||
repr(o))
|
||||
return self.default(o)
|
||||
|
||||
return text
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue