ignore_exc should return default values
Justylol opened this issue · 1 comments
Justylol commented
Its better for ignore_exc to use default value on return, instead of None. It will be real missing cache behaviour and will help with errors when default expected. For example:
Django==3.2
djangorestframework==3.11.1
pymemcache==3.5.0
rest_framework.throttling module
self.history = self.cache.get(self.key, [])
self.now = self.timer()
# Drop any requests from the history which have now passed the
# throttle duration
while self.history and self.history[-1] <= self.now - self.duration:
self.history.pop()
if len(self.history) >= self.num_requests:
return self.throttle_failure()
This code with in Django with PyMemcacheCache cache backend and ignore_exc option leads to an error object of type 'NoneType' has no len()
because instead of returning list as missing cache result, it returns None.