Issue #28634: Fix asyncio.isfuture() to support mocks

This commit is contained in:
Yury Selivanov 2016-11-07 16:00:50 -05:00
parent 3b3a141a83
commit 49d6b8c0c3
2 changed files with 26 additions and 2 deletions

View file

@ -2,7 +2,7 @@
__all__ = ['CancelledError', 'TimeoutError',
'InvalidStateError',
'Future', 'wrap_future',
'Future', 'wrap_future', 'isfuture',
]
import concurrent.futures._base
@ -117,7 +117,8 @@ def isfuture(obj):
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: