summaryrefslogtreecommitdiffstats
path: root/Lib/asyncio/events.py
diff options
context:
space:
mode:
authorKumar Aditya <rahuladitya303@gmail.com>2021-12-06 23:40:35 (GMT)
committerGitHub <noreply@github.com>2021-12-06 23:40:35 (GMT)
commit265918bb1d782ab85c7dbc835eb62d6cfc2145b7 (patch)
treed3f63cd07b8465aed76dfc04839d388c28bf87c2 /Lib/asyncio/events.py
parent8518ee348c18da7e150f5e42b3424c86f7c0a3d8 (diff)
downloadcpython-265918bb1d782ab85c7dbc835eb62d6cfc2145b7.zip
cpython-265918bb1d782ab85c7dbc835eb62d6cfc2145b7.tar.gz
cpython-265918bb1d782ab85c7dbc835eb62d6cfc2145b7.tar.bz2
bpo-23819: asyncio: Replace AssertionError with TypeError where it makes sense (GH-29894)
Diffstat (limited to 'Lib/asyncio/events.py')
-rw-r--r--Lib/asyncio/events.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/Lib/asyncio/events.py b/Lib/asyncio/events.py
index 7abaaca..d91fe8d 100644
--- a/Lib/asyncio/events.py
+++ b/Lib/asyncio/events.py
@@ -101,7 +101,6 @@ class TimerHandle(Handle):
__slots__ = ['_scheduled', '_when']
def __init__(self, when, callback, args, loop, context=None):
- assert when is not None
super().__init__(callback, args, loop, context)
if self._source_traceback:
del self._source_traceback[-1]
@@ -661,7 +660,8 @@ class BaseDefaultEventLoopPolicy(AbstractEventLoopPolicy):
def set_event_loop(self, loop):
"""Set the event loop."""
self._local._set_called = True
- assert loop is None or isinstance(loop, AbstractEventLoop)
+ if loop is not None and not isinstance(loop, AbstractEventLoop):
+ raise TypeError(f"loop must be an instance of AbstractEventLoop or None, not '{type(loop).__name__}'")
self._local._loop = loop
def new_event_loop(self):
@@ -745,7 +745,8 @@ def set_event_loop_policy(policy):
If policy is None, the default policy is restored."""
global _event_loop_policy
- assert policy is None or isinstance(policy, AbstractEventLoopPolicy)
+ if policy is not None and not isinstance(policy, AbstractEventLoopPolicy):
+ raise TypeError(f"policy must be an instance of AbstractEventLoopPolicy or None, not '{type(policy).__name__}'")
_event_loop_policy = policy