From d61491d0f31b92c88dc470f0154cce363ce2ee2c Mon Sep 17 00:00:00 2001 From: Ronny Pfannschmidt Date: Wed, 1 Mar 2023 18:06:27 +0100 Subject: [PATCH] use stderr=true instead of file=sys.stderr for traceback handler install --- CHANGELOG.md | 1 + CONTRIBUTORS.md | 1 + rich/traceback.py | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b8cfd514..456fb7b0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - Fixed pretty printing of empty dataclass https://github.com/Textualize/rich/issues/2819 +- Use `Console(stderr=True)` in `rich.traceback.install` to support io redirection. ## [13.3.1] - 2023-01-28 diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index e300c8b3..108789a6 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -37,6 +37,7 @@ The following people have contributed to the development of Rich: - [Dave Pearson](https://github.com/davep/) - [Avi Perl](https://github.com/avi-perl) - [Laurent Peuch](https://github.com/psycojoker) +- [Ronny Pfannschmidt](https://github.com/RonnyPfannschmidt/) - [Olivier Philippon](https://github.com/DrBenton) - [Kylian Point](https://github.com/p0lux) - [Kyle Pollina](https://github.com/kylepollina) diff --git a/rich/traceback.py b/rich/traceback.py index e8dc737b..eb0a7a92 100644 --- a/rich/traceback.py +++ b/rich/traceback.py @@ -86,7 +86,7 @@ def install( Callable: The previous exception handler that was replaced. """ - traceback_console = Console(file=sys.stderr) if console is None else console + traceback_console = Console(stderr=True) if console is None else console locals_hide_sunder = ( True