Skip to content

Commit

Permalink
Merge branch 'master' into bugfix-inconsistent-coloring-of-complex-nu…
Browse files Browse the repository at this point in the history
…mbers
  • Loading branch information
willmcgugan committed Apr 26, 2022
2 parents 9ae04d2 + ed6ff7e commit a02e5d6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -19,6 +19,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Safari - Box appearing around SVG export https://github.com/Textualize/rich/pull/2201
- Fixed recursion error in Jupyter progress bars https://github.com/Textualize/rich/issues/2047
- Complex numbers are now identified by the highlighter https://github.com/Textualize/rich/issues/2214
- Fix crash on IDLE and forced is_terminal detection to False because IDLE can't do escape codes https://github.com/Textualize/rich/issues/2222

### Changed

Expand Down
9 changes: 8 additions & 1 deletion rich/console.py
Expand Up @@ -915,6 +915,13 @@ def is_terminal(self) -> bool:
"""
if self._force_terminal is not None:
return self._force_terminal

if hasattr(sys.stdin, "__module__") and sys.stdin.__module__.startswith(
"idlelib"
):
# Return False for Idle which claims to be a tty but can't handle ansi codes
return False

isatty: Optional[Callable[[], bool]] = getattr(self.file, "isatty", None)
try:
return False if isatty is None else isatty()
Expand Down Expand Up @@ -969,7 +976,7 @@ def size(self) -> ConsoleDimensions:
if WINDOWS: # pragma: no cover
try:
width, height = os.get_terminal_size()
except OSError: # Probably not a terminal
except (AttributeError, ValueError, OSError): # Probably not a terminal
pass
else:
for file_descriptor in _STD_STREAMS:
Expand Down

0 comments on commit a02e5d6

Please sign in to comment.