| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
…getattr__ hasattr() only treats AttributeError as "attribute not found"; any other exception propagates. FanoutCache.__getattr__ used a bare assert for an unknown attribute name, so hasattr(cache, name) raised instead of returning False for anything outside the known settings, breaking tools that probe attributes with hasattr() (e.g. pympler's asizeof). Fixes grantjenks#353
| Back | FazBrowse Home | New Git URL |
Fixes #353.
Bug
FanoutCache.__getattr__ uses a bare assert to reject unknown attribute names:
hasattr() only swallows AttributeError; any other exception propagates. So hasattr(FanoutCache(), 'anything_unknown') raises AssertionError instead of returning False. This breaks code that probes objects with hasattr(), such as pympler's asizeof, which crashed the pympler debug toolbar panel when it checked hasattr(cache, '__slots__').
Fix
Raise AttributeError instead of asserting, which is what __getattr__ is expected to raise for an unknown attribute per the data model, and is what hasattr() actually checks for.
Test plan