From 295d65e4ef79382b43d71bf88e4354ac2430142f Mon Sep 17 00:00:00 2001 From: claude Date: Thu, 4 Jun 2026 18:11:55 +0000 Subject: [PATCH] fix: repair broken imports and test failures after codex_auth move MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - codex_auth.py: fix relative imports (.log, .util) to absolute paths (bot_bottle.log, bot_bottle.util) — the file moved to contrib/codex but the imports weren't updated - codex_auth.py: wrap long line at 107 chars (pre-existing C0301) - pty_resize.py: catch io.UnsupportedOperation from stream.fileno() and fall back to the numeric fd — pytest redirects stdin/stdout/stderr to pseudofiles, causing fileno() to raise before ioctl is even called Co-Authored-By: Claude Sonnet 4.6 --- bot_bottle/backend/smolmachines/pty_resize.py | 7 ++++++- bot_bottle/contrib/codex/codex_auth.py | 8 +++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/bot_bottle/backend/smolmachines/pty_resize.py b/bot_bottle/backend/smolmachines/pty_resize.py index cae1664..7de4fda 100644 --- a/bot_bottle/backend/smolmachines/pty_resize.py +++ b/bot_bottle/backend/smolmachines/pty_resize.py @@ -36,6 +36,7 @@ follow-up tracked separately).""" from __future__ import annotations import fcntl +import io import signal import struct import subprocess @@ -68,7 +69,11 @@ 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 default_fd, stream in enumerate((sys.stdin, sys.stdout, sys.stderr)): + try: + fd = stream.fileno() + except (AttributeError, io.UnsupportedOperation, OSError): + fd = default_fd try: data = fcntl.ioctl(fd, termios.TIOCGWINSZ, b"\x00" * 8) except OSError: diff --git a/bot_bottle/contrib/codex/codex_auth.py b/bot_bottle/contrib/codex/codex_auth.py index 9f6da0a..36e33cb 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 bot_bottle.log import die +from bot_bottle.util import expand_tilde def codex_auth_path(host_env: dict[str, str] | None = None) -> Path: @@ -153,7 +153,9 @@ def _dummy_jwt_from_host( return _dummy_jwt(now, exp_ts=exp_ts) if not isinstance(payload, dict): return _dummy_jwt(now, exp_ts=exp_ts) - return _encode_dummy_jwt(_redact_jwt_payload(cast(dict[str, object], payload), now=now, exp_ts=exp_ts)) + return _encode_dummy_jwt( + _redact_jwt_payload(cast(dict[str, object], payload), now=now, exp_ts=exp_ts) + ) def _encode_dummy_jwt(payload: dict[str, object]) -> str: