fix encoding

This commit is contained in:
Will McGugan 2020-12-31 17:53:11 +00:00
parent ea049ffc14
commit 481f30f237
4 changed files with 15 additions and 4 deletions

View File

@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [9.6.1] - 2020-12-31
### Fixed
- Fixed encoding error on Windows when loading code on Windows
## [9.6.0] - 2020-12-30
### Changed

View File

@ -2,7 +2,7 @@
name = "rich"
homepage = "https://github.com/willmcgugan/rich"
documentation = "https://rich.readthedocs.io/en/latest/"
version = "9.6.0"
version = "9.6.1"
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

@ -99,6 +99,7 @@ DEFAULT_STYLES: Dict[str, Style] = {
"table.cell": Style.null(),
"table.title": Style(italic=True),
"table.caption": Style(italic=True, dim=True),
"traceback.error": Style(dim=True, color="red", bold=True),
"traceback.border.syntax_error": Style(color="bright_red"),
"traceback.border": Style(color="red"),
"traceback.text": Style.null(),

View File

@ -443,7 +443,9 @@ class Traceback:
"""
code = code_cache.get(filename)
if code is None:
with open(filename, "rt") as code_file:
with open(
filename, "rt", encoding="utf-8", errors="replace"
) as code_file:
code = code_file.read()
code_cache[filename] = code
return code
@ -492,8 +494,10 @@ class Traceback:
indent_guides=self.indent_guides,
)
yield ""
except Exception:
pass
except Exception as error:
yield Text.assemble(
(f"{error.__class__.__name__}: {error}", "traceback.error"),
)
else:
yield (
Columns(