From 7ce396ea59e97b577185ee536f1830f3e47b11d5 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Mon, 3 Oct 2022 12:08:56 +0530 Subject: [PATCH] fix: handle isatty correctly (#18277) (#18278) sys.stdin can be `None` [skip ci] (cherry picked from commit 35ba00a54ec1adc05afd2ae35c03bc0b8adbf346) Co-authored-by: Ankush Menat --- frappe/__init__.py | 2 +- frappe/utils/__init__.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/frappe/__init__.py b/frappe/__init__.py index 2dbf1e4c7f..7e8a7f9620 100644 --- a/frappe/__init__.py +++ b/frappe/__init__.py @@ -453,7 +453,7 @@ def msgprint( if as_list and type(msg) in (list, tuple): out.as_list = 1 - if sys.stdin.isatty(): + if sys.stdin and sys.stdin.isatty(): msg = _strip_html_tags(out.message) if flags.print_messages and out.message: diff --git a/frappe/utils/__init__.py b/frappe/utils/__init__.py index 1ffdfc883d..45ecfc0bac 100644 --- a/frappe/utils/__init__.py +++ b/frappe/utils/__init__.py @@ -560,7 +560,7 @@ def is_cli() -> bool: try: invoked_from_terminal = bool(os.get_terminal_size()) except Exception: - invoked_from_terminal = sys.stdin.isatty() + invoked_from_terminal = sys.stdin and sys.stdin.isatty() return invoked_from_terminal