mirror of
https://github.com/agent0ai/agent-zero.git
synced 2026-07-09 17:08:29 +00:00
Fix pytest capture import in TTY session
Guard stream reconfiguration so pytest capture objects without reconfigure support can import the code execution TTY helper while preserving UTF-8 error handling for normal streams.
This commit is contained in:
parent
528c33b7ef
commit
a18a35977a
1 changed files with 9 additions and 2 deletions
|
|
@ -6,9 +6,16 @@ if _IS_WIN:
|
|||
import msvcrt
|
||||
|
||||
|
||||
def _reconfigure_stream_errors(stream) -> None:
|
||||
reconfigure = getattr(stream, "reconfigure", None)
|
||||
if not callable(reconfigure):
|
||||
return
|
||||
reconfigure(errors="replace")
|
||||
|
||||
|
||||
# Make stdin / stdout tolerant to broken UTF-8 so input() never aborts
|
||||
sys.stdin.reconfigure(errors="replace") # type: ignore
|
||||
sys.stdout.reconfigure(errors="replace") # type: ignore
|
||||
_reconfigure_stream_errors(sys.stdin)
|
||||
_reconfigure_stream_errors(sys.stdout)
|
||||
|
||||
|
||||
# ──────────────────────────── PUBLIC CLASS ────────────────────────────
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue