Skip to content

Commit 770276d

Browse files
authored
Actually fix the api curses crash. (python#8396)
I refactored after I tested, which was a mistake.
1 parent 9ff569c commit 770276d

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

mypy/util.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import subprocess
66
import sys
77
import hashlib
8+
import io
89

910
from typing import (
1011
TypeVar, List, Tuple, Optional, Dict, Sequence, Iterable, Container, IO, Callable
@@ -545,11 +546,13 @@ def initialize_unix_colors(self) -> bool:
545546
# setupterm wants a fd to potentially write an "initialization sequence".
546547
# We override sys.stdout for the daemon API so if stdout doesn't have an fd,
547548
# just give it /dev/null.
548-
if hasattr(sys.stdout, 'fileno'):
549-
curses.setupterm()
550-
else:
549+
try:
550+
fd = sys.stdout.fileno()
551+
except io.UnsupportedOperation:
551552
with open("/dev/null", "rb") as f:
552553
curses.setupterm(fd=f.fileno())
554+
else:
555+
curses.setupterm(fd=fd)
553556
except curses.error:
554557
# Most likely terminfo not found.
555558
return False

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy