Skip to content

Conversation

spyoungtech
Copy link

@spyoungtech spyoungtech commented Oct 23, 2021

Resolves #260

Uses similar approach to the cached_property_with_ttl decorator.

Using the same example from #260 the exception no longer contains a KeyError:

Traceback (most recent call last):
  File "t.py", line 15, in <module>
    m.boardwalk
  File "/Users/spencer.young/repos/cached-property/cached_property.py", line 75, in __get__
    return obj_dict.setdefault(name, self.func(obj))
  File "t.py", line 11, in boardwalk
    self.boardwalk_price += 1/0
ZeroDivisionError: division by zero

Hopefully this will reduce confusion for users, such as in situations like this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

threaded_cached_property can raise confusing exception

1 participant