IIRC at very early stages Guido van Rossum decided to *freeze* `CancelledError`: user code should not derive from the exception. Like you never derive from StopIteration.
On Sun, Dec 3, 2017 at 8:00 AM Chris Jerdonek <chris.jerdo...@gmail.com> wrote: > Hi, I want to ask how people feel about the following. > > If you raise a subclass of CancelledError from within a task and then > call task.result(), CancelledError is raised rather than the subclass. > > Here is some code to illustrate: > > class MyCancelledError(CancelledError): pass > > async def raise_my_cancel(): > raise MyCancelledError() > > task = asyncio.ensure_future(raise_my_cancel()) > try: > await task > except Exception: > pass > assert task.cancelled() > # Raises CancelledError and not MyCancelledError. > task.result() > > Does this seem right to people? Is there a justification for this? > > If it would help for the discussion, I could provide a use case. > > Thanks a lot, > --Chris > _______________________________________________ > Async-sig mailing list > Async-sig@python.org > https://mail.python.org/mailman/listinfo/async-sig > Code of Conduct: https://www.python.org/psf/codeofconduct/ > -- Thanks, Andrew Svetlov
_______________________________________________ Async-sig mailing list Async-sig@python.org https://mail.python.org/mailman/listinfo/async-sig Code of Conduct: https://www.python.org/psf/codeofconduct/