issue with traceback on legacy windows

This commit is contained in:
Will McGugan 2020-05-08 14:02:20 +01:00
parent 3617dc4fa0
commit b16db0c7e6
3 changed files with 14 additions and 5 deletions

View File

@ -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

View File

@ -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 <willmcgugan@gmail.com>"]
license = "MIT"

View File

@ -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()
@ -266,12 +270,11 @@ class Console:
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: