We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent f96f7c9 commit cc9ee36Copy full SHA for cc9ee36
1 file changed
Lib/json/tool.py
@@ -87,14 +87,11 @@ def main():
87
infile = sys.stdin
88
else:
89
infile = open(options.infile, encoding='utf-8')
90
- try:
91
- if options.json_lines:
92
- objs = (json.loads(line) for line in infile)
93
- else:
94
- objs = (json.load(infile),)
95
- finally:
96
- if infile is not sys.stdin:
97
- infile.close()
+
+ if options.json_lines:
+ objs = (json.loads(line) for line in infile)
+ else:
+ objs = (json.load(infile),)
98
99
if options.outfile is None:
100
outfile = sys.stdout
@@ -111,6 +108,8 @@ def main():
111
108
for obj in objs:
112
109
json.dump(obj, outfile, **dump_args)
113
110
outfile.write('\n')
+ if infile is not sys.stdin:
+ infile.close()
114
except ValueError as e:
115
raise SystemExit(e)
116
0 commit comments