jfhbrook / pyee

A rough port of Node.js's EventEmitter to Python with a few tricks of its own
https://github.com/jfhbrook/public
MIT License
371 stars 39 forks source link

[Regression]: EventEmitter.listeners("foo") throws if no listener exists #103

Closed mxschmitt closed 2 years ago

mxschmitt commented 2 years ago

The following:

from pyee import EventEmitter
ee = EventEmitter()
ee.listeners("foo")

results in:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/.../env/lib/python3.10/site-packages/pyee/base.py", line 229, in listeners
    return list(self._events[event].keys())
KeyError: 'foo'
>>> 

since version 9.0.0. In version <8 it was returning an empty list instead. This most likely broke in #99 when the defaultdict of EventEmitter._events got changed to a normal dict.

jfhbrook commented 2 years ago

Yeah, sounds like a regression. I'll patch shortly.

jfhbrook commented 2 years ago

Released your patch as 9.0.1 - thanks so much!!