Skip to content
This repository was archived by the owner on Nov 23, 2017. It is now read-only.
This repository was archived by the owner on Nov 23, 2017. It is now read-only.

CoroWrapper in debug mode has incorrect throw method signature #429

@Bahus

Description

@Bahus

Hello!

When PYTHONASYNCIODEBUG is set asyncio wraps each coroutine in special CoroWrapperclass which has incorrect signature for throw method:

def throw(self, exc):
    return self.gen.throw(exc)

However it should be:

def throw(self, type, value=None, traceback=None):
    return self.gen.throw(type, value, traceback)

For example the problem appears when I'm using Tornado web-server with enabled asyncio debugging mode exception thrown in a coroutine causes another one:

Traceback (most recent call last):
  File ".../lib/python3.5/site-packages/tornado/web.py", line 1445, in _execute
    result = yield result
  File ".../lib/python3.5/site-packages/tornado/gen.py", line 1008, in run
    value = future.result()
  File ".../lib/python3.5/site-packages/tornado/concurrent.py", line 232, in result
    raise_exc_info(self._exc_info)
  File "<string>", line 3, in raise_exc_info
  File ".../lib/python3.5/site-packages/tornado/gen.py", line 1014, in run
    yielded = self.gen.throw(*exc_info)
  File "<string>", line 6, in _wrap_awaitable
TypeError: throw() takes 2 positional arguments but 4 were given

See tornado's code here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions