Skip to content

Commit 52ec0cd

Browse files
committed
fix: make python -m json with nothing not hang
Signed-off-by: yihong0618 <[email protected]>
1 parent c056a08 commit 52ec0cd

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

Lib/json/tool.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,11 @@ def main():
7272
help='suppress all whitespace separation (most compact)')
7373
options = parser.parse_args()
7474

75+
# Check if reading from stdin in a terminal without piped input
76+
if options.infile == '-' and sys.stdin.isatty():
77+
parser.print_help()
78+
return
79+
7580
dump_args = {
7681
'sort_keys': options.sort_keys,
7782
'indent': options.indent,

0 commit comments

Comments
 (0)