@@ -101,7 +101,6 @@ class TimerHandle(Handle):
101101 __slots__ = ['_scheduled' , '_when' ]
102102
103103 def __init__ (self , when , callback , args , loop , context = None ):
104- assert when is not None
105104 super ().__init__ (callback , args , loop , context )
106105 if self ._source_traceback :
107106 del self ._source_traceback [- 1 ]
@@ -661,7 +660,8 @@ def get_event_loop(self):
661660 def set_event_loop (self , loop ):
662661 """Set the event loop."""
663662 self ._local ._set_called = True
664- assert loop is None or isinstance (loop , AbstractEventLoop )
663+ if loop is not None and not isinstance (loop , AbstractEventLoop ):
664+ raise TypeError (f"loop must be an instance of AbstractEventLoop or None, not '{ type (loop ).__name__ } '" )
665665 self ._local ._loop = loop
666666
667667 def new_event_loop (self ):
@@ -745,7 +745,8 @@ def set_event_loop_policy(policy):
745745
746746 If policy is None, the default policy is restored."""
747747 global _event_loop_policy
748- assert policy is None or isinstance (policy , AbstractEventLoopPolicy )
748+ if policy is not None and not isinstance (policy , AbstractEventLoopPolicy ):
749+ raise TypeError (f"policy must be an instance of AbstractEventLoopPolicy or None, not '{ type (policy ).__name__ } '" )
749750 _event_loop_policy = policy
750751
751752
0 commit comments