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

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


http://hg.python.org/cpython/rev/6996a53f13ce
changeset: 80640:6996a53f13ce
branch: 3.2
parent: 80636:44c544809e6c
user: Ezio Melotti <ezio.melotti at gmail.com>
date: Thu Nov 29 02:25:03 2012 +0200
summary:
 #16476: Fix json.tool to avoid including trailing whitespace.
files:
 Lib/json/tool.py | 3 ++-
 Lib/test/json_tests/test_tool.py | 16 ++++++++--------
 Misc/NEWS | 2 ++
 3 files changed, 12 insertions(+), 9 deletions(-)
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 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')
 
 
diff --git a/Lib/test/json_tests/test_tool.py b/Lib/test/json_tests/test_tool.py
--- a/Lib/test/json_tests/test_tool.py
+++ b/Lib/test/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/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -167,6 +167,8 @@
 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.
 
-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /