renpy / pygame_sdl2

Reimplementation of portions of the pygame API using SDL2.
GNU Lesser General Public License v2.1
325 stars 63 forks source link

EventType.__eq__ doesn't handle other is None #152

Open ajbaldocchi opened 4 months ago

ajbaldocchi commented 4 months ago

EventType.eq has the following implementation: def __eq__(self, other): return self.__dict__ == other.__dict__

if other is None, this results in the following AttributeError: File "src/pygame_sdl2/event.pyx", line 90, in pygame_sdl2.event.EventType.__eq__ AttributeError: 'NoneType' object has no attribute '__dict__'

This precludes checks like event == other when other can at any point be None.

When using ren'py 8.1.3, this can be reproduced by using SetScreenVariable to set a screen variable defaulting to None to a pygame_sdl2 EventType object; get_selected() attempts to perform the above equality check (more specifically, cs.scope[self.name] == self.value) and results in this AttributeError.