This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vrutsky
Recipients gvanrossum, vrutsky, vstinner, yselivanov
Date 2015-11-17.12:47:19
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1447764440.4.0.175921042664.issue25648@psf.upfronthosting.co.za>
In-reply-to
Content
In Python 3.4.3 with enabled asyncio debug a function is
wrapped using the following code in @asyncio.coroutine:

@functools.wraps(func)
def wrapper(*args, **kwds):
    w = CoroWrapper(coro(*args, **kwds), func)
    if w._source_traceback:
        del w._source_traceback[-1]
    w.__name__ = func.__name__
    if hasattr(func, '__qualname__'):
        w.__qualname__ = func.__qualname__
    w.__doc__ = func.__doc__
    return w

The unconditional access to "__name__" and "__doc__" attributes may fail in some circumstances.

As this case looks strange and unrealistic I met it in a real
application that used mocking in tests. The code there was something like the following:

def f():
    return "f result"

mocked_f = Mock(wraps=f)
coro_func = asyncio.coroutine(mocked_f)
print(loop.run_until_complete(coro_func()))
mocked_f.assert_called_once_with() 

Here is complete example:
https://gist.github.com/rutsky/65cee7728135b05d49c3

This issue is fixed in 95964:957478e95b26 changeset during adding support of async/await syntax, so it is not reproduced in Python 3.5 or 3.4 head, but still reproducible in latest released version of Python 3.4 branch: 3.4.3.

So until 3.4.4 is released this issue still may be considered as not fixed.
History
Date User Action Args
2015-11-17 12:47:20vrutskysetrecipients: + vrutsky, gvanrossum, vstinner, yselivanov
2015-11-17 12:47:20vrutskysetmessageid: <1447764440.4.0.175921042664.issue25648@psf.upfronthosting.co.za>
2015-11-17 12:47:20vrutskylinkissue25648 messages
2015-11-17 12:47:19vrutskycreate