Skip to content

Commit 3921b20

Browse files
committed
chore: move errors into core under the import catch block
1 parent 3fd6059 commit 3921b20

File tree

2 files changed

+11
-15
lines changed

2 files changed

+11
-15
lines changed

Diff for: asyncio/core.py

+11-3
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,24 @@
2424
except ImportError:
2525
from .task import TaskQueue, Task
2626

27+
################################################################################
28+
# Exceptions
29+
30+
2731
# Depending on the release of CircuitPython these errors may or may not
2832
# exist in the C implementation of `_asyncio`. However, when they
2933
# do exist, they must be preferred over the Python code.
3034
try:
3135
from _asyncio import CancelledError, InvalidStateError
3236
except (ImportError, AttributeError):
33-
from .task import CancelledError, InvalidStateError
37+
class CancelledError(BaseException):
38+
"""Injected into a task when calling `Task.cancel()`"""
39+
pass
3440

35-
################################################################################
36-
# Exceptions
41+
42+
class InvalidStateError(Exception):
43+
"""Can be raised in situations like setting a result value for a task object that already has a result value set."""
44+
pass
3745

3846

3947
class TimeoutError(Exception):

Diff for: asyncio/task.py

-12
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,6 @@
2121
from . import core
2222

2323

24-
class CancelledError(BaseException):
25-
"""Injected into a task when calling `Task.cancel()`"""
26-
27-
pass
28-
29-
30-
class InvalidStateError(Exception):
31-
"""Can be raised in situations like setting a result value for a task object that already has a result value set."""
32-
33-
pass
34-
35-
3624
# pairing-heap meld of 2 heaps; O(1)
3725
def ph_meld(h1, h2):
3826
if h1 is None:

0 commit comments

Comments
 (0)