Marco Pagliaricci <pagliaricc...@gmail.com> added the comment:
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, M. On Thu, Oct 7, 2021 at 10:25 AM Thomas Grainger <rep...@bugs.python.org> wrote: > > Thomas Grainger <tagr...@gmail.com> added the comment: > > afaik this is intentional https://bugs.python.org/issue31033 > > ---------- > nosy: +graingert > > _______________________________________ > Python tracker <rep...@bugs.python.org> > <https://bugs.python.org/issue45390> > _______________________________________ > ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue45390> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com