diff options
Diffstat (limited to 'lib-python/3/json/tool.py')
-rw-r--r-- | lib-python/3/json/tool.py | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/lib-python/3/json/tool.py b/lib-python/3/json/tool.py index 5932f4ecde..c136fb7d3b 100644 --- a/lib-python/3/json/tool.py +++ b/lib-python/3/json/tool.py @@ -20,9 +20,9 @@ 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') - 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') parser.add_argument('--sort-keys', action='store_true', default=False, help='sort the output of dictionaries alphabetically by key') @@ -42,4 +42,7 @@ def main(): if __name__ == '__main__': - main() + try: + main() + except BrokenPipeError as exc: + sys.exit(exc.errno) |