Skip to content

Commit

Permalink
Merge pull request #2224 from Textualize/idle-fix
Browse files Browse the repository at this point in the history
Idle fix
  • Loading branch information
willmcgugan committed Apr 26, 2022
2 parents a3b7e0e + 1aa9061 commit ed6ff7e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -18,6 +18,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Fixed markup escaping issue https://github.com/Textualize/rich/issues/2187
- 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
- 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
7 changes: 7 additions & 0 deletions 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

0 comments on commit ed6ff7e

Please sign in to comment.