You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Nov 23, 2017. It is now read-only.
Repository navigation
This repository was archived by the owner on Nov 23, 2017. It is now read-only.
Hi @methane, thank you for the link.
On the mailing-list, Stefan seems to find a solution: cython/cython@4af4244
I've played my role of messenger: I've invited him to open a pull request.
It's not clear to me what the best fix is here, but my gut feeling tells me that the correct way to deal with this is to create a Generator ABC and do the type checking based on that. A "Generator" is an object that implements the Generator protocol, not necessarily something of type types.GeneratorType. Special casing that type is fine, obviously, but excluding everything else isn't.
The fact that this crash bug here went unnoticed since Py3.3 makes it obvious, though, that no-one has ever tried this at the C level:
I think adding Coroutine ABC to somewhere is good way to solve this problem.
It may be in the stdlib. But I think we should wait discussion of async/await syntax.
For now, how about asyncio.coroutines.Coroutine ?
fromabcimportABCMeta, abstractmethodimporttypesclassCoroutine(metaclass=ABCMeta):
def__iter__(self):
returnselfdef__next__(self):
raiseStopIteration@abstractmethoddefsend(self):
raiseStopIterationCoroutine.register(types.GeneratorType)
Coroutine.register(CoroWrapper)
defiscoroutine(obj):
"""Return True if obj is a coroutine object."""returnisinstance(obj, Coroutine)
Activity
gvanrossum commentedon Apr 20, 2015
Agreed, I would gladly accept patches. I'm not a Cython user myself so I can't fix this without help.
ludovic-gasc commentedon Apr 20, 2015
Hi @methane, thank you for the link.
On the mailing-list, Stefan seems to find a solution: cython/cython@4af4244
I've played my role of messenger: I've invited him to open a pull request.
scoder commentedon Apr 20, 2015
I had already created a CPython ticket for this:
https://bugs.python.org/issue24004
Here's what Cython currently (as in "since yesterday") does in order to circumvent the type checks in asyncio and inspect:
https://github.com/cython/cython/blob/4af42443bd37f6207143f8870904f780a65bb3e3/Cython/Utility/Generator.c#L824
https://github.com/cython/cython/blob/4af42443bd37f6207143f8870904f780a65bb3e3/Cython/Utility/Generator.c#L906
It's not clear to me what the best fix is here, but my gut feeling tells me that the correct way to deal with this is to create a Generator ABC and do the type checking based on that. A "Generator" is an object that implements the Generator protocol, not necessarily something of type
types.GeneratorType. Special casing that type is fine, obviously, but excluding everything else isn't.The fact that this crash bug here went unnoticed since Py3.3 makes it obvious, though, that no-one has ever tried this at the C level:
https://bugs.python.org/issue23996
methane commentedon Apr 20, 2015
I think adding
CoroutineABC to somewhere is good way to solve this problem.It may be in the stdlib. But I think we should wait discussion of async/await syntax.
For now, how about
asyncio.coroutines.Coroutine?1st1 commentedon May 13, 2015
@scoder You can now use
collections.abc.Coroutinefor your purposes (3a09a93). Closing this issue.