Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Idle fix #2224

Merged
merged 4 commits into from Apr 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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