Skip to content

Commit 5cea88a

Browse files
committed
bpo-33684: json.tool: Use utf-8 for infile and outfile.
1 parent 6f52d15 commit 5cea88a

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

Lib/json/tool.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,12 @@ def main():
2020
description = ('A simple command line interface for json module '
2121
'to validate and pretty-print JSON objects.')
2222
parser = argparse.ArgumentParser(prog=prog, description=description)
23-
parser.add_argument('infile', nargs='?', type=argparse.FileType(),
23+
parser.add_argument('infile', nargs='?',
24+
type=argparse.FileType(encoding="utf-8"),
2425
help='a JSON file to be validated or pretty-printed',
2526
default=sys.stdin)
26-
parser.add_argument('outfile', nargs='?', type=argparse.FileType('w'),
27+
parser.add_argument('outfile', nargs='?',
28+
type=argparse.FileType('w', encoding="utf-8"),
2729
help='write the output of infile to outfile',
2830
default=sys.stdout)
2931
parser.add_argument('--sort-keys', action='store_true', default=False,

0 commit comments

Comments
 (0)