Author jaraco
Recipients jaraco, rhettinger
Date 2019-04-17.18:52:55
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1555527175.53.0.856355244653.issue36650@roundup.psfhosted.org>
In-reply-to
Content
I've put together this full reproducer script:

```
import functools


def method_cache(method):
	def wrapper(self, *args, **kwargs):
		# it's the first call, replace the method with a cached, bound method
		bound_method = functools.partial(method, self)
		cached_method = functools.lru_cache()(bound_method)
		setattr(self, method.__name__, cached_method)
		return cached_method(*args, **kwargs)
	return wrapper


class MyClass:
	calls = 0

	@method_cache
	def call_me_maybe(self, number):
		self.calls += 1
		return number


ob = MyClass()
ob.call_me_maybe(0)
ob.call_me_maybe(0)
assert ob.calls == 1
```

That code fails on Python 3.7.3. If I bypass the `from _functools import _lru_cache_wrapper` in functools, the test no longer fails, so the issue seems to be only with the C implementation.
History
Date User Action Args
2019-04-17 18:52:55jaracosetrecipients: + jaraco, rhettinger
2019-04-17 18:52:55jaracosetmessageid: <1555527175.53.0.856355244653.issue36650@roundup.psfhosted.org>
2019-04-17 18:52:55jaracolinkissue36650 messages
2019-04-17 18:52:55jaracocreate