mirror of
https://github.com/python/cpython.git
synced 2025-08-25 11:15:02 +00:00
This reverts commit 365451e283
.
This commit is contained in:
parent
ed037d229f
commit
a8ffe66154
3 changed files with 8 additions and 48 deletions
|
@ -32,6 +32,14 @@ def get_colors(colorize: bool = False) -> ANSIColors:
|
|||
|
||||
|
||||
def can_colorize() -> bool:
|
||||
if sys.platform == "win32":
|
||||
try:
|
||||
import nt
|
||||
|
||||
if not nt._supports_virtual_terminal():
|
||||
return False
|
||||
except (ImportError, AttributeError):
|
||||
return False
|
||||
if not sys.flags.ignore_environment:
|
||||
if os.environ.get("PYTHON_COLORS") == "0":
|
||||
return False
|
||||
|
@ -50,15 +58,6 @@ def can_colorize() -> bool:
|
|||
if not hasattr(sys.stderr, "fileno"):
|
||||
return False
|
||||
|
||||
if sys.platform == "win32":
|
||||
try:
|
||||
import nt
|
||||
|
||||
if not nt._supports_virtual_terminal():
|
||||
return False
|
||||
except (ImportError, AttributeError):
|
||||
return False
|
||||
|
||||
try:
|
||||
return os.isatty(sys.stderr.fileno())
|
||||
except io.UnsupportedOperation:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue