[New-bugs-announce] [issue24004] avoid explicit generator type check in asyncio

Stefan Behnel report at bugs.python.org
Sun Apr 19 12:21:02 CEST 2015


New submission from Stefan Behnel:

asyncio/coroutines.py contains this code:

"""
_COROUTINE_TYPES = (types.GeneratorType, CoroWrapper)

def iscoroutine(obj):
    """Return True if obj is a coroutine object."""
    return isinstance(obj, _COROUTINE_TYPES)
"""

In other places, it uses inspect.isgenerator() to do the same thing. This is inconsistent and should be changed. Code that wants to patch inspect.isgenerator() in order to support other generator types shouldn't also have to patch asyncio directly, and code that wants to support other generator types in asyncio shouldn't have to patch both places either.

----------
components: asyncio
messages: 241506
nosy: gvanrossum, haypo, scoder, yselivanov
priority: normal
severity: normal
status: open
title: avoid explicit generator type check in asyncio
type: behavior
versions: Python 3.4, Python 3.5

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue24004>
_______________________________________


More information about the New-bugs-announce mailing list