From 6364fdfbcab8428ca8dc389dbfe475dbb427dca5 Mon Sep 17 00:00:00 2001 From: "Jeong, YunWon" Date: Mon, 8 Dec 2025 20:43:46 +0900 Subject: [PATCH] No windows legacy terminal support when no ctypes --- CHANGELOG.md | 4 ++++ CONTRIBUTORS.md | 1 + rich/console.py | 6 ++++++ 3 files changed, 11 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e53205666f..1b4becc4a2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,10 @@ 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). +### Changed + +- Don't use windows legacy terminal support when ctypes is not available. + ## [14.2.0] - 2025-10-09 ### Changed diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 4b04786b9c..2089260779 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -16,6 +16,7 @@ The following people have contributed to the development of Rich: - [Ed Davis](https://github.com/davised) - [Pete Davison](https://github.com/pd93) - [James Estevez](https://github.com/jstvz) +- [Jeong, YunWon](https://github.com/youknowone) - [Jonathan Eunice](https://github.com/jonathan-3play) - [Aryaz Eghbali](https://github.com/AryazE) - [Oleksis Fraga](https://github.com/oleksis) diff --git a/rich/console.py b/rich/console.py index 994adfc069..86ae13cea0 100644 --- a/rich/console.py +++ b/rich/console.py @@ -581,6 +581,12 @@ def get_windows_console_features() -> "WindowsConsoleFeatures": # pragma: no co def detect_legacy_windows() -> bool: """Detect legacy Windows.""" + try: + import ctypes # noqa: F401 + except ImportError: + # No ctypes doesn't mean no legacy windows, + # but legacy windows mode requires ctypes, so we force it off. + return False return WINDOWS and not get_windows_console_features().vt