Skip to content

Commit

Permalink
issue with traceback on legacy windows
Browse files Browse the repository at this point in the history
  • Loading branch information
willmcgugan committed May 8, 2020
1 parent 3617dc4 commit b16db0c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [1.0.1] - 2020-05-08

### Fixed

- Issue with Windows legacy support https://github.com/willmcgugan/rich/issues/59

## [1.0.1] - 2020-05-08

### Changed

- Applied console markup after highlighting
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "rich"
homepage = "https://github.com/willmcgugan/rich"
documentation = "https://rich.readthedocs.io/en/latest/"
version = "1.0.1"
version = "1.0.2"
description = "Render rich text, tables, progress bars, syntax highlighting, markdown and more to the terminal"
authors = ["Will McGugan <[email protected]>"]
license = "MIT"
Expand Down
11 changes: 7 additions & 4 deletions rich/console.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,12 @@ class ConsoleThreadLocals(threading.local):
control: List[str] = field(default_factory=list)


def _enable_legacy_windows_support() -> None:
"""Initialize Windows legacy support."""
def detect_legacy_windows() -> bool:
"""Detect legacy Windows."""
return "WINDIR" in os.environ and "WT_SESSION" not in os.environ


if detect_legacy_windows():
from colorama import init

init()
Expand Down Expand Up @@ -266,12 +270,11 @@ def __init__(
self._markup = markup
self._emoji = emoji
self._highlight = highlight
self.legacy_windows: bool = "WINDIR" in os.environ and not "WT_SESSION" in os.environ
self.legacy_windows: bool = detect_legacy_windows()

self._color_system: Optional[ColorSystem]
self._force_terminal = force_terminal
if self.legacy_windows:
_enable_legacy_windows_support()
self.file = file or sys.stdout
self._color_system = COLOR_SYSTEMS["windows"]
else:
Expand Down

0 comments on commit b16db0c

Please sign in to comment.