#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 679ae83..b5d4fca 100644
--- 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
index 9ec3440..fe47c52 100644
--- 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
index 7af9a68..55bed50 100644
--- 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.