Skip to content

Commit 33f37fc

Browse files
Check for stdout/stderr in case file descriptor is closed (#1620)
1 parent 11f3262 commit 33f37fc

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

src/pipx/animate.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from pipx.constants import WINDOWS
88
from pipx.emojis import EMOJI_SUPPORT
99

10-
stderr_is_tty = sys.stderr.isatty()
10+
stderr_is_tty = bool(sys.stderr and sys.stderr.isatty())
1111

1212
CLEAR_LINE = "\033[K"
1313
EMOJI_ANIMATION_FRAMES = ["⣷", "⣯", "⣟", "⡿", "⢿", "⣻", "⣽", "⣾"]

src/pipx/colors.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
except ImportError: # Colorama is Windows only package
77
colorama = None
88

9-
PRINT_COLOR = sys.stdout.isatty()
9+
PRINT_COLOR = bool(sys.stdout and sys.stdout.isatty())
1010

1111
if PRINT_COLOR and colorama:
1212
colorama.init()

src/pipx/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1050,7 +1050,7 @@ def setup_log_file() -> Path:
10501050

10511051

10521052
def setup_logging(verbose: int) -> None:
1053-
pipx_str = bold(green("pipx >")) if sys.stdout.isatty() else "pipx >"
1053+
pipx_str = (sys.stdout and sys.stdout.isatty() and bold(green("pipx >"))) or "pipx >"
10541054
paths.ctx.log_file = setup_log_file()
10551055

10561056
# Determine logging level, a value between 0 and 50

0 commit comments

Comments
 (0)