bpo-33684: json.tool: Use utf-8 for infile and outfile. (GH-17460)

This commit is contained in:
Inada Naoki 2019-12-04 18:39:31 +09:00 committed by GitHub
parent 24f5cac725
commit 808769f3a4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 24 additions and 5 deletions

View file

@ -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,