Fix remove_event_handler's loop

This commit is contained in:
Lonami Exo 2018-04-08 11:22:59 +02:00
parent e69c186782
commit 5fd6155168

View File

@ -2276,8 +2276,10 @@ class TelegramClient(TelegramBareClient):
if event and not isinstance(event, type):
event = type(event)
for i, ec in enumerate(self._event_builders):
ev, cb = ec
i = len(self._event_builders)
while i:
i -= 1
ev, cb = self._event_builders[i]
if cb == callback and (not event or isinstance(ev, event)):
del self._event_builders[i]
found += 1