Author: Armin Rigo <[email protected]>
Branch:
Changeset: r97196:f48b6c5fe1ca
Date: 2019-08-16 11:36 +0200
http://bitbucket.org/pypy/pypy/changeset/f48b6c5fe1ca/
Log: Un-fix the broken attempt at emulating bug-to-bug compatibility, and
instead just give the "correct" result in all cases.
diff --git a/extra_tests/test_json.py b/extra_tests/test_json.py
--- a/extra_tests/test_json.py
+++ b/extra_tests/test_json.py
@@ -52,6 +52,10 @@
== '{"3": 4, "5": 6}'
def test_boolean_as_dict_key():
- # it's this way in CPython 2.x. In 3.x it was fixed
- assert json.dumps({True: 5}) == '{"True": 5}' # != '{"true": 5}'
- assert json.dumps({False: 5}) == '{"False": 5}'
+ # In CPython 2.x, dumps({True:...}) gives {"True":...}. It should be
+ # "true" instead; it's a bug as far as I can tell. In 3.x it was fixed.
+ # BUT! if we call dumps() with sort_keys=True, then CPython (any version)
+ # gives "true" instead of "True". Surprize!
+ # I don't want to understand why, let's just not attempt to reproduce that.
+ assert json.dumps({True: 5}) == '{"true": 5}'
+ assert json.dumps({False: 5}) == '{"false": 5}'
diff --git a/lib-python/2.7/json/encoder.py b/lib-python/2.7/json/encoder.py
--- a/lib-python/2.7/json/encoder.py
+++ b/lib-python/2.7/json/encoder.py
@@ -301,9 +301,9 @@
elif isinstance(key, float):
key = self.__floatstr(key)
elif key is True:
- key = 'True' # XXX != 'true', bug-to-bug compatibility
+ key = 'true'
elif key is False:
- key = 'False' # XXX != 'false', bug-to-bug compatibility
+ key = 'false'
elif key is None:
key = 'null'
elif isinstance(key, (int, long)):
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit