Skip to content

Commit

Permalink
fix traceback for missing frame file
Browse files Browse the repository at this point in the history
  • Loading branch information
willmcgugan committed Mar 4, 2023
1 parent 73093c2 commit 3469674
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Use `Console(stderr=True)` in `rich.traceback.install` to support io redirection.
- Fixes superfluous spaces in html output https://github.com/Textualize/rich/issues/2832
- Fixed duplicate output in Jupyter https://github.com/Textualize/rich/pulls/2804
- Fixes traceback failing when a frame filename is unreadable https://github.com/Textualize/rich/issues/2821

### Added

Expand Down
8 changes: 7 additions & 1 deletion rich/traceback.py
Original file line number Diff line number Diff line change
Expand Up @@ -664,7 +664,13 @@ def render_locals(frame: Frame) -> Iterable[ConsoleRenderable]:
style="pygments.text",
)
else:
text = Text.assemble("in ", (frame.name, "pygments.function"))
text = Text.assemble(
"in ",
(frame.name, "pygments.function"),
(":", "pygments.text"),
(str(frame.lineno), "pygments.number"),
style="pygments.text",
)
if not frame.filename.startswith("<") and not first:
yield ""
yield text
Expand Down

0 comments on commit 3469674

Please sign in to comment.