Skip to content

Commit 29d01fe

Browse files
committed
bpo-27413: --no-ensure-ascii argument in json.tool
Closes https://bugs.python.org/issue27413
1 parent 4fb3bb3 commit 29d01fe

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

Lib/json/tool.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def main():
3737
help='a JSON file to be validated or pretty-printed')
3838
parser.add_argument('outfile', nargs='?', type=argparse.FileType('w'),
3939
help='write the output of infile to outfile')
40-
parser.add_argument('--no_escape', action='store_true', default=False,
40+
parser.add_argument('--no-ensure-ascii', action='store_true', default=False,
4141
help='Do not set ensure_ascii to escape non-ASCII characters')
4242
parser.add_argument('--indent', default='4', type=parse_indent,
4343
help='Indent level or str for pretty-printing. '
@@ -64,7 +64,7 @@ def main():
6464
with outfile:
6565
json.dump(obj, outfile,
6666
indent=options.indent,
67-
ensure_ascii=not options.no_escape,
67+
ensure_ascii=not options.no_ensure_ascii,
6868
sort_keys=options.sort_keys,
6969
)
7070
outfile.write('\n')

Lib/test/test_json/test_tool.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ def test_no_ascii_flag(self):
115115
}
116116
''')
117117
infile = self._create_infile(data)
118-
rc, out, err = assert_python_ok('-m', 'json.tool', '--no_ascii', infile)
118+
rc, out, err = assert_python_ok('-m', 'json.tool', '--no-ensure-ascii', infile)
119119
self.assertEqual(rc, 0)
120-
self.assertEqual(out.splitlines(), expect.splitlines())
120+
self.assertEqual(out.splitlines(), expect.encode().splitlines())
121121
self.assertEqual(err, b'')

0 commit comments

Comments
 (0)