[New-bugs-announce] [issue8814] functools.WRAPPER_ASSIGNMENTS should include __annotations__

Terrence Cole report at bugs.python.org
Mon May 24 23:20:59 CEST 2010


New submission from Terrence Cole <terrence at zettabytestorage.com>:

__annotations__ should be included in the set of attributes copied by default to a wrapped method.

An example of the problem:
>>> from functools import wraps
>>> def mydecorator(fn):
...     @wraps(fn)
...     def inner(*args, **kwargs):
...         return fn(*args, **kwargs)
...     return inner
...
>>> @mydecorator
... def foo(a:int, b:str):
...     pass
... 
>>> foo.__annotations__
{}

With the included fix:
>>> foo.__annotations__
{'a': <class 'int'>, 'b': <class 'str'>}

----------
components: Library (Lib)
files: functools-wrapper-assign-annotations.diff
keywords: patch
messages: 106394
nosy: terrence
priority: normal
severity: normal
status: open
title: functools.WRAPPER_ASSIGNMENTS should include __annotations__
type: behavior
versions: Python 3.1, Python 3.2, Python 3.3
Added file: http://bugs.python.org/file17453/functools-wrapper-assign-annotations.diff

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


More information about the New-bugs-announce mailing list