diff --git a/Lib/json/tests/test_tool.py b/Lib/json/tests/test_tool.py index 679ae835467..b5d4fca4fa3 100644 --- a/Lib/json/tests/test_tool.py +++ b/Lib/json/tests/test_tool.py @@ -19,19 +19,19 @@ class TestTool(unittest.TestCase): [ [ "blorpie" - ], + ], [ "whoops" - ], - [], - "d-shtaeou", - "d-nthiouh", - "i-vhbjkhnth", + ], + [], + "d-shtaeou", + "d-nthiouh", + "i-vhbjkhnth", { "nifty": 87 - }, + }, { - "field": "yes", + "field": "yes", "morefield": false } ] diff --git a/Lib/json/tool.py b/Lib/json/tool.py index 9ec34401ee5..fe47c52d416 100644 --- a/Lib/json/tool.py +++ b/Lib/json/tool.py @@ -31,7 +31,8 @@ def main(): except ValueError, e: raise SystemExit(e) with outfile: - json.dump(obj, outfile, sort_keys=True, indent=4) + json.dump(obj, outfile, sort_keys=True, + indent=4, separators=(',', ': ')) outfile.write('\n') diff --git a/Misc/NEWS b/Misc/NEWS index 7af9a68dcd7..55bed5083ae 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -154,6 +154,8 @@ Core and Builtins Library ------- +- Issue #16476: Fix json.tool to avoid including trailing whitespace. + - Issue #1160: Fix compiling large regular expressions on UCS2 builds. Patch by Serhiy Storchaka.