Gregory P. Smith <g...@krypto.org> added the comment:

the pure python functools.lru_cache doesn't get this right either.  here's a 
desirable testcase for this bug:

```
    def test_lru_defaults_bug44003(self):
        @self.module.lru_cache(maxsize=None)
        def func(arg='ARG', *, kw='KW'):
            return arg, kw

        self.assertEqual(func.__wrapped__.__defaults__, ('ARG',))
        self.assertEqual(func.__wrapped__.__kwdefaults__, {'kw': 'KW'})
        self.assertEqual(func.__defaults__, ('ARG',))
        self.assertEqual(func.__kwdefaults__, {'kw': 'KW'})
```

results in

```
ERROR: test_lru_defaults_bug44003 (test.test_functools.TestLRUC)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/greg/oss/python/gpshead/Lib/test/test_functools.py", line 1738, 
in test_lru_defaults_bug44003
    self.assertEqual(func.__defaults__, ('ARG',))
AttributeError: 'functools._lru_cache_wrapper' object has no attribute 
'__defaults__'

======================================================================
FAIL: test_lru_defaults_bug44003 (test.test_functools.TestLRUPy)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/greg/oss/python/gpshead/Lib/test/test_functools.py", line 1738, 
in test_lru_defaults_bug44003
    self.assertEqual(func.__defaults__, ('ARG',))
AssertionError: None != ('ARG',)
```

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue44003>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to