@@ -243,6 +243,43 @@ def test_ipc_event_descriptor_direct_init():
243243 _event_module .IPCEventDescriptor ()
244244
245245
246+ @pytest .mark .parametrize (
247+ "other" ,
248+ [None , "string" , 42 , 3.14 , (b"\x00 " * 64 ,), object ()],
249+ ids = ["None" , "str" , "int" , "float" , "tuple" , "object" ],
250+ )
251+ def test_ipc_event_descriptor_eq_other_type (other ):
252+ """IPCEventDescriptor.__eq__ returns NotImplemented for unrelated types.
253+
254+ Regression test for https://github.com/NVIDIA/cuda-python/issues/2050: comparing
255+ an IPCEventDescriptor to objects of unrelated types must not raise TypeError /
256+ AttributeError; it must follow Python's rich-comparison protocol and yield False.
257+ """
258+ import cuda .core ._event as _event_module
259+
260+ desc = _event_module .IPCEventDescriptor ._init (b"\x00 " * 64 , True )
261+ assert desc != other
262+ assert not (desc == other ) # noqa: SIM201
263+ assert other != desc
264+ assert desc .__eq__ (other ) is NotImplemented
265+
266+
267+ def test_ipc_event_descriptor_eq_same_value ():
268+ """Two IPCEventDescriptors with the same _reserved compare equal."""
269+ import cuda .core ._event as _event_module
270+
271+ reserved = b"\x01 " * 64
272+ a = _event_module .IPCEventDescriptor ._init (reserved , True )
273+ b = _event_module .IPCEventDescriptor ._init (reserved , True )
274+ c = _event_module .IPCEventDescriptor ._init (b"\x02 " * 64 , True )
275+ assert a == a
276+ assert a == b
277+ assert a != c
278+ # _is_blocking_sync is intentionally ignored by __eq__.
279+ d = _event_module .IPCEventDescriptor ._init (reserved , False )
280+ assert a == d
281+
282+
246283# ============================================================================
247284# Event Hash Tests
248285# ============================================================================
0 commit comments