Skip to content

Commit 73a4fb1

Browse files
committed
Implement extra checks in can_colorize
1 parent 15c840a commit 73a4fb1

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

Lib/traceback.py

+5
Original file line numberDiff line numberDiff line change
@@ -155,11 +155,16 @@ def _can_colorize():
155155
return True
156156
if os.environ.get("TERM") == "dumb":
157157
return False
158+
159+
if not hasattr(sys.stderr, "fileno"):
160+
return False
161+
158162
try:
159163
return os.isatty(sys.stderr.fileno())
160164
except io.UnsupportedOperation:
161165
return sys.stderr.isatty()
162166

167+
163168
def _print_exception_bltin(exc, /):
164169
file = sys.stderr if sys.stderr is not None else sys.__stderr__
165170
colorize = _can_colorize()

0 commit comments

Comments
 (0)