From 808769f3a4cbdc47cf1a5708dd61b1787bb192d4 Mon Sep 17 00:00:00 2001 From: Inada Naoki Date: Wed, 4 Dec 2019 18:39:31 +0900 Subject: bpo-33684: json.tool: Use utf-8 for infile and outfile. (GH-17460) --- Lib/json/tool.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'Lib/json/tool.py') diff --git a/Lib/json/tool.py b/Lib/json/tool.py index 6c687d77c5..2a404a4441 100644 --- a/Lib/json/tool.py +++ b/Lib/json/tool.py @@ -20,10 +20,12 @@ def main(): description = ('A simple command line interface for json module ' 'to validate and pretty-print JSON objects.') parser = argparse.ArgumentParser(prog=prog, description=description) - parser.add_argument('infile', nargs='?', type=argparse.FileType(), + parser.add_argument('infile', nargs='?', + type=argparse.FileType(encoding="utf-8"), help='a JSON file to be validated or pretty-printed', default=sys.stdin) - parser.add_argument('outfile', nargs='?', type=argparse.FileType('w'), + parser.add_argument('outfile', nargs='?', + type=argparse.FileType('w', encoding="utf-8"), help='write the output of infile to outfile', default=sys.stdout) parser.add_argument('--sort-keys', action='store_true', default=False, -- cgit v1.2.1