Skip to content

bug: _confirm_install_r_packages only catches EOFError, not BrokenPipeError #129

@MitchellAcoustics

Description

@MitchellAcoustics

Description

In _confirm_install_r_packages() (src/soundscapy/r_wrapper/_r_wrapper.py), the try/except EOFError block only catches EOFError from input(). If print() raises BrokenPipeError (e.g. in a redirected-stdout environment like python -c "..." | head), the exception propagates uncaught through the dependency-check path, crashing what should be a graceful "should we install?" prompt.

Reproduction

python -c "import soundscapy.spi" | head -1
# BrokenPipeError propagates from print() inside _confirm_install_r_packages

Fix

Broaden the caught exception to cover OSError (which BrokenPipeError is a subclass of):

try:
    print(...)
    response = input("Install them now via soundscapy? [y/N] ").strip().lower()
except (EOFError, OSError):
    pass
else:
    return response in ("y", "yes")

Notes

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions