Bug report
Bug description:
Minimal Reproduction
from functools import cached_property
class Example:
  @cached_property
  def data(self):
      return None.some_attribute  # Raises AttributeError
  def __getattr__(self, name):
      return "FALLBACK"
obj = Example()
print(obj.data)  # Expected: AttributeError, Got: "FALLBACK"Expected Behavior
AttributeError should be raised: 'NoneType' object has no attribute 'some_attribute'
Actual Behavior
Returns "FALLBACK" (from getattr)
Impact
- hasattr(obj, 'data') returns True (wrong)
- getattr(obj, 'data', 'DEFAULT') returns "FALLBACK" instead of 'DEFAULT'
- Silent failures instead of fast failures
- Difficult to debug
Root Cause
Python's descriptor protocol treats AttributeError from get as "attribute doesn't exist", triggering getattr fallback.
Python Versions
Workaround
Don't use @cached_property with classes that have getattr, or manually wrap exceptions.
Proposal
Add a ignore_error parameters to cached_property and property
CPython versions tested on:
CPython main branch, 3.13
Operating systems tested on:
Linux