Skip to content

Commit 874f893

Browse files
committed
Added default value for the "source" parameter in the trio.Cancelled initializer
This restores backwards compatibility with AnyIO.
1 parent 4ff5c30 commit 874f893

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/trio/_core/_exceptions.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ class Cancelled(BaseException, metaclass=NoPublicConstructor):
8282
8383
"""
8484

85-
source: CancelReasonLiteral
85+
source: CancelReasonLiteral = "unknown"
8686
# repr(Task), so as to avoid gc troubles from holding a reference
8787
source_task: str | None = None
8888
reason: str | None = None
@@ -114,7 +114,7 @@ def __reduce__(self) -> tuple[Callable[[], Cancelled], tuple[()]]:
114114
def _create(
115115
cls,
116116
*,
117-
source: CancelReasonLiteral,
117+
source: CancelReasonLiteral = "unknown",
118118
source_task: str | None = None,
119119
reason: str | None = None,
120120
) -> Self: ...

0 commit comments

Comments
 (0)