Ethan Furman added the comment:
The added tests for inf, -inf, and nan are good.
The refactoring of the dictionary tests are not good. The reason is that
before _json.c was fixed (issue18264) it would return the string value of an
IntEnum instead of the string value of the IntEnum member's value attribute.
--> class Number(IntEnum):
... one = 1
... two = 2
--> json.dumps(Number.one)
'Number.one' # should be '1'
As a constant we get a failure when trying to round-trip:
--> json.loads(json.dumps(Number.one))
Traceback (most recent call last):
...
ValueError: Expecting value: line 1 column 1 (char 0)
But as a dictionary we do not (because keys get morphed into strings):
--> json.dumps({Number.one: 'one'})
'{"Number.one": "one"}' # should be '{"1": "one"}'
Which round-trips fine, but yields the wrong result:
>>> loads(dumps({Number.one: 'one'}))
{'Number.one': 'one'} # should be {'1': 'one'}
So the dictionary tests (and the list tests) are there to make sure that
json.dumps is converting them properly, not to make sure that they round-trip,
and by changing from repr to loads/dumps the point of the test is lost.
Updated tests attached.
----------
Added file: http://bugs.python.org/file31493/issue18745.stoneleaf.01.patch
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue18745>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com