]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
#16476: Fix json.tool to avoid including trailing whitespace.
authorEzio Melotti <ezio.melotti@gmail.com>
Thu, 29 Nov 2012 00:25:03 +0000 (02:25 +0200)
committerEzio Melotti <ezio.melotti@gmail.com>
Thu, 29 Nov 2012 00:25:03 +0000 (02:25 +0200)
Lib/json/tool.py
Lib/test/json_tests/test_tool.py
Misc/NEWS

index 9ab6d6546a8a505667eb2d762211fda59f78a5e8..0f108c6dae4bcf48d69629f166cf6cdd39b64f50 100644 (file)
@@ -31,7 +31,8 @@ def main():
         except ValueError as 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')
 
 
index 8a3cc6f77f5cb67a3d90387256f50adca9d410ed..1f2c8a2442047b9091db9765b61d2fe34727aacd 100644 (file)
@@ -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
         }
     ]
index 48c5111a90bdd6b1a4ba9a7107cf8a543df5b2fa..39eed9107927be71cc48e9f7bb1fc3cf5094a98f 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -167,6 +167,8 @@ Core and Builtins
 Library
 -------
 
+- Issue #16476: Fix json.tool to avoid including trailing whitespace.
+
 - Issue #16549: Make json.tool work again on Python 3 and add tests.
   Initial patch by Berker Peksag and Serhiy Storchaka.