Message392623
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. |
|
Date |
User |
Action |
Args |
2021-05-01 19:49:53 | gregory.p.smith | set | recipients:
+ gregory.p.smith, serhiy.storchaka |
2021-05-01 19:49:53 | gregory.p.smith | set | messageid: <1619898593.46.0.475516317903.issue44003@roundup.psfhosted.org> |
2021-05-01 19:49:53 | gregory.p.smith | link | issue44003 messages |
2021-05-01 19:49:53 | gregory.p.smith | create | |
|