From 030af02ac142aca0219cb64ac47f0de73b252060 Mon Sep 17 00:00:00 2001 From: claude Date: Thu, 4 Jun 2026 18:18:26 +0000 Subject: [PATCH] fix: correct broken imports and fileno() guard after rebase MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit codex_auth.py was moved into contrib/codex/ but still used `.log`/ `.util` relative imports that resolved to the parent bot_bottle package before the move — update to `...log` / `...util`. _read_winsize() called sys.stdin.fileno() outside the OSError guard; pytest's redirected stdin raises UnsupportedOperation (an OSError subclass) there, breaking test_returns_first_tty_size. Move fileno() inside the try block so any non-TTY stream is skipped cleanly. --- bot_bottle/backend/smolmachines/pty_resize.py | 3 ++- bot_bottle/contrib/codex/codex_auth.py | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/bot_bottle/backend/smolmachines/pty_resize.py b/bot_bottle/backend/smolmachines/pty_resize.py index cae1664..e4cbb00 100644 --- a/bot_bottle/backend/smolmachines/pty_resize.py +++ b/bot_bottle/backend/smolmachines/pty_resize.py @@ -68,8 +68,9 @@ def _read_winsize() -> tuple[int, int] | None: - tmux respawn-pane: tmux sets all three to the pane's PTY. - non-TTY (someone piped stdin in tests): none are; the sync just no-ops, which is the right behavior.""" - for fd in (sys.stdin.fileno(), sys.stdout.fileno(), sys.stderr.fileno()): + for stream in (sys.stdin, sys.stdout, sys.stderr): try: + fd = stream.fileno() data = fcntl.ioctl(fd, termios.TIOCGWINSZ, b"\x00" * 8) except OSError: continue diff --git a/bot_bottle/contrib/codex/codex_auth.py b/bot_bottle/contrib/codex/codex_auth.py index 9f6da0a..d38ecb6 100644 --- a/bot_bottle/contrib/codex/codex_auth.py +++ b/bot_bottle/contrib/codex/codex_auth.py @@ -15,8 +15,8 @@ from datetime import datetime, timezone from pathlib import Path from typing import cast -from .log import die -from .util import expand_tilde +from ...log import die +from ...util import expand_tilde def codex_auth_path(host_env: dict[str, str] | None = None) -> Path: