From: Ezio Melotti Date: Thu, 29 Nov 2012 00:22:49 +0000 (+0200) Subject: #16476: Fix json.tool to avoid including trailing whitespace. X-Git-Tag: v2.7.4rc1~342 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=def6ee59793c7f43b9dcb0c635650b322834d445;p=thirdparty%2FPython%2Fcpython.git #16476: Fix json.tool to avoid including trailing whitespace. --- diff --git a/Lib/json/tests/test_tool.py b/Lib/json/tests/test_tool.py index 679ae8354676..b5d4fca4fa3c 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 9ec34401ee5c..fe47c52d4163 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 7af9a68dcd7e..55bed5083ae3 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.