[New-bugs-announce] [issue24400] Awaitable ABC incompatible with functools.singledispatch

Ben Darnell report at bugs.python.org
Sun Jun 7 07:06:53 CEST 2015

New submission from Ben Darnell:

The new collections.abc.Awaitable ABC relies on __instancecheck__, which makes it incompatible with functools.singledispatch (singledispatch works based on args[0].__class__; any instance-level information is discarded). This surprised me because the first thing I tried to do with Awaitable was add it to my singledispatch-based coroutine compatibility layer.

Ideally coroutine would be an actual subclass of generator, instead of a generator with an extra bit set on the instance that changes how it answers isinstance() checks. That would be a big change, though, so it might be better to just document that Awaitable is kind of unusual (if we weren't already in the beta period I might argue that the ABCs should be removed and we should just use the functions in the inspect module instead).

components: asyncio
messages: 244942
nosy: Ben.Darnell, gvanrossum, haypo, yselivanov
priority: normal
severity: normal
status: open
title: Awaitable ABC incompatible with functools.singledispatch
versions: Python 3.5

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list