Skip to content

Commit

Permalink
Fix Handler unregister (#1050)
Browse files Browse the repository at this point in the history
Add checking for handler_obj.handler
  • Loading branch information
butvinm committed Nov 6, 2022
1 parent 707988b commit 19e97de
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions aiogram/dispatcher/handler.py
Expand Up @@ -74,11 +74,12 @@ def unregister(self, handler):
:param handler: callback
:return:
"""

for handler_obj in self.handlers:
registered = handler_obj.handler
if handler in self.handlers:
self.handlers.remove(handler)
if handler == handler_obj or handler == handler_obj.handler:
self.handlers.remove(handler_obj)
return True

raise ValueError('This handler is not registered!')

async def notify(self, *args):
Expand Down

0 comments on commit 19e97de

Please sign in to comment.