From 52ec0cd18ea8534cf68a7fe99586462a3666f9ac Mon Sep 17 00:00:00 2001 From: yihong0618 Date: Thu, 21 Aug 2025 15:33:35 +0800 Subject: [PATCH] fix: make python -m json with nothing not hang Signed-off-by: yihong0618 --- Lib/json/tool.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Lib/json/tool.py b/Lib/json/tool.py index 1967817add8abc..13c9c10f837b7e 100644 --- a/Lib/json/tool.py +++ b/Lib/json/tool.py @@ -72,6 +72,11 @@ def main(): help='suppress all whitespace separation (most compact)') options = parser.parse_args() + # Check if reading from stdin in a terminal without piped input + if options.infile == '-' and sys.stdin.isatty(): + parser.print_help() + return + dump_args = { 'sort_keys': options.sort_keys, 'indent': options.indent,