This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author pagliaricci.m
Recipients asvetlov, bjs, chris.jerdonek, graingert, pagliaricci.m, yselivanov
Date 2021-10-09.07:38:23
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
In-reply-to <>
OK, I see your point.
But I still can't understand one thing and I think it's very confusing:

1) if you see my example, inside the job() coroutine, I get correctly
cancelled with an `asyncio.CancelledError` exception containing my message.
2) Now: if I re-raise the asyncio.CancelledError as-is, I lose the message,
if I call the `asyncio.Task.exception()` function.
3) If I raise a *new* asyncio.CancelledError with a new message, inside the
job() coroutine's `except asyncio.CancelledError:` block, I still lose the
message if I call `asyncio.Task.exception()`.
4) But if I raise another exception, say `raise ValueError("TEST")`, always
from the `except asyncio.CancelledError:` block of the job() coroutine, I
*get* the message!
I get `ValueError("TEST")` by calling `asyncio.Task.exception()`, while I
don't with the `asyncio.CancelledError()` one.

Is this really wanted? Sorry, but I still find this a lot confusing.
Shouldn't it be better to return from the `asyncio.Task.exception()` the
old one (containing the message) ?
Or, otherwise, create a new instance of the exception for *ALL* the
exception classes?

Thank you for your time,
My Best Regards,


On Thu, Oct 7, 2021 at 10:25 AM Thomas Grainger <>

> Thomas Grainger <> added the comment:
> afaik this is intentional
> ----------
> nosy: +graingert
> _______________________________________
> Python tracker <>
> <>
> _______________________________________
Date User Action Args
2021-10-09 07:38:23pagliaricci.msetrecipients: + pagliaricci.m, asvetlov, chris.jerdonek, yselivanov, graingert, bjs
2021-10-09 07:38:23pagliaricci.mlinkissue45390 messages
2021-10-09 07:38:23pagliaricci.mcreate