Issue #28634: Fix asyncio.isfuture() to support mocks
diff --git a/Lib/asyncio/futures.py b/Lib/asyncio/futures.py
index bcd4d16..9ca8d84 100644
--- a/Lib/asyncio/futures.py
+++ b/Lib/asyncio/futures.py
@@ -2,7 +2,7 @@
__all__ = ['CancelledError', 'TimeoutError',
'InvalidStateError',
- 'Future', 'wrap_future',
+ 'Future', 'wrap_future', 'isfuture',
]
import concurrent.futures._base
@@ -117,7 +117,8 @@
itself as duck-type compatible by setting _asyncio_future_blocking.
See comment in Future for more details.
"""
- return getattr(obj, '_asyncio_future_blocking', None) is not None
+ return (hasattr(obj.__class__, '_asyncio_future_blocking') and
+ obj._asyncio_future_blocking is not None)
class Future: