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 gregory.p.smith
Recipients gregory.p.smith, serhiy.storchaka
Date 2021-05-01.19:49:53
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1619898593.46.0.475516317903.issue44003@roundup.psfhosted.org>
In-reply-to
Content
When the C implementation of functools.lru_cache was added in bpo/issue14373, it appears to have omitted setting `.__defaults__` on its wrapped function.


```
Python 3.10.0a7+ (heads/master-dirty:823fbf4e0e, May  1 2021, 11:10:30) [Clang 12.0.0 (clang-1200.0.32.29)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import functools
>>> def func(b=5): pass
... 
>>> @functools.lru_cache
... def cached_func(b=5): pass
... 
>>> func.__defaults__
(5,)
>>> cached_func.__defaults__
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'functools._lru_cache_wrapper' object has no attribute '__defaults__'
```

functools.update_wrapper() does set __defaults__ so this appears to just be an oversight in Modules/_functoolsmodule.c.
History
Date User Action Args
2021-05-01 19:49:53gregory.p.smithsetrecipients: + gregory.p.smith, serhiy.storchaka
2021-05-01 19:49:53gregory.p.smithsetmessageid: <1619898593.46.0.475516317903.issue44003@roundup.psfhosted.org>
2021-05-01 19:49:53gregory.p.smithlinkissue44003 messages
2021-05-01 19:49:53gregory.p.smithcreate