fix: Windows-incompatible python's inspect file guard in LazyModule - #3065
fix: Windows-incompatible python's inspect file guard in LazyModule#3065Need-an-AwP wants to merge 1 commit into
Conversation
|
Independent confirmation, from a different and more consequential failure mode than #2798 (which only affected test collection). This breaks Minimal repro needs no pyannote at all: Confirmed this PR's fix ( One thing worth flagging for anyone hitting this in the meantime: Would be great to see this merged — it's a one-line fix for a guard whose intent (per the existing code comment about "PyTorch's op registering machinery") is already exactly right. |
What does this PR do?
On Windows, inspect.py lives at paths like
C:\Python311\Lib\inspect.py, so this guard never triggers. Lazy modules with optional dependencies (notablyspeechbrain.integrations.k2_fsa, which requiresk2) can be imported unintentionally during normal model loading, causing hardImportErrorcrashes on Windows even when k2 is never used.Replace the slash-specific
endswith("/inspect.py")check withos.path.basename(importer_frame.filename) == "inspect.py".osis already imported in this file; no new dependencies.Before submitting
PR review
Reviewer checklist