Skip to content

fix(audio_io): remove unreachable duplicate except in torchcodec probe - #1487

Open
Anai-Guo wants to merge 1 commit into
ModelTC:mainfrom
Anai-Guo:fix-audio-io-dup-except
Open

fix(audio_io): remove unreachable duplicate except in torchcodec probe#1487
Anai-Guo wants to merge 1 commit into
ModelTC:mainfrom
Anai-Guo:fix-audio-io-dup-except

Conversation

@Anai-Guo

@Anai-Guo Anai-Guo commented Sep 5, 2026

Copy link
Copy Markdown

Problem

In lightx2v/utils/audio_io.py, the torchcodec import probe declares two identical except Exception handlers:

try:
    import torchcodec  # noqa: F401
except Exception:
    _TORCHAUDIO_DECODE_AVAILABLE = False
except Exception as e:                       # unreachable
    print(f"Error importing torchcodec: {e}")
    _TORCHAUDIO_DECODE_AVAILABLE = False
else:
    _TORCHAUDIO_DECODE_AVAILABLE = True

Two handlers for the same exception type in one try are evaluated top-down, so the first (silent) handler always wins and the second — the one that actually logs why the probe failed — is unreachable dead code.

Fix

Drop the redundant silent handler and keep the informative one, so an import failure is reported instead of swallowed:

try:
    import torchcodec  # noqa: F401
except Exception as e:
    print(f"Error importing torchcodec: {e}")
    _TORCHAUDIO_DECODE_AVAILABLE = False
else:
    _TORCHAUDIO_DECODE_AVAILABLE = True

One-hunk change; behavior on success is unchanged, and a failing probe now surfaces the underlying error.

🤖 Generated with Claude Code

The torchcodec import probe had two identical `except Exception` handlers.
The first (silent) one shadows the second, so the handler that logs the
import error was dead code. Drop the redundant silent handler so the
intended error message is emitted on failure.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant