[Python-checkins] cpython (2.7): #16476: Fix json.tool to avoid including trailing whitespace.

ezio.melotti python-checkins at python.org
Thu Nov 29 01:27:53 CET 2012


http://hg.python.org/cpython/rev/fa277ab588de
changeset:   80639:fa277ab588de
branch:      2.7
parent:      80635:08e5973fdc7e
user:        Ezio Melotti <ezio.melotti at gmail.com>
date:        Thu Nov 29 02:22:49 2012 +0200
summary:
  #16476: Fix json.tool to avoid including trailing whitespace.

files:
  Lib/json/tests/test_tool.py |  16 ++++++++--------
  Lib/json/tool.py            |   3 ++-
  Misc/NEWS                   |   2 ++
  3 files changed, 12 insertions(+), 9 deletions(-)


diff --git a/Lib/json/tests/test_tool.py b/Lib/json/tests/test_tool.py
--- a/Lib/json/tests/test_tool.py
+++ b/Lib/json/tests/test_tool.py
@@ -19,19 +19,19 @@
     [
         [
             "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
--- a/Lib/json/tool.py
+++ b/Lib/json/tool.py
@@ -31,7 +31,8 @@
         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
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -154,6 +154,8 @@
 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.
 

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list