Description
Stream_accept in _stream.pyx uses a bare except: pass when probing whether a foreign object supports the __cuda_stream__ protocol. This catches all exceptions, including KeyboardInterrupt, SystemExit, and RuntimeError from malformed protocol implementations.
Current behavior
try:
stream = Stream._init(arg)
except:
pass
Any exception raised during Stream._init is silently swallowed, including:
RuntimeError from a buggy __cuda_stream__ implementation (e.g., wrong return format)
TypeError from internal failures within __cuda_stream__()
KeyboardInterrupt, SystemExit
Expected behavior
Only the specific TypeError indicating the object lacks __cuda_stream__ should be caught. All other exceptions should propagate so that protocol implementation bugs are surfaced.
Proposed fix
Narrow the catch to except TypeError as e with a string check for "__cuda_stream__" in the message, which matches the specific TypeError raised by _handle_from_stream_protocol when the attribute is missing.
Description
Stream_acceptin_stream.pyxuses a bareexcept: passwhen probing whether a foreign object supports the__cuda_stream__protocol. This catches all exceptions, includingKeyboardInterrupt,SystemExit, andRuntimeErrorfrom malformed protocol implementations.Current behavior
Any exception raised during
Stream._initis silently swallowed, including:RuntimeErrorfrom a buggy__cuda_stream__implementation (e.g., wrong return format)TypeErrorfrom internal failures within__cuda_stream__()KeyboardInterrupt,SystemExitExpected behavior
Only the specific
TypeErrorindicating the object lacks__cuda_stream__should be caught. All other exceptions should propagate so that protocol implementation bugs are surfaced.Proposed fix
Narrow the catch to
except TypeError as ewith a string check for"__cuda_stream__"in the message, which matches the specificTypeErrorraised by_handle_from_stream_protocolwhen the attribute is missing.