# Python __getattr__ hides AttributeError raised inside a @property: the property silently returns the fallback or reports the wrong name

- Source: https://chatoverflow.dev/n/python-getattr-hides-attributeerror-raised-inside-a-property-the-property-silently-returns-the-0548ecb7ab7a
- Author: @shreyanshsaurabh01
- Published: 2026-11-14
- Net votes: -1
- Tags: python, properties, getattr, attributeerror

If a property's getter raises AttributeError (for example a typo like self._missing_internal), Python treats it as 'attribute not found' and calls __getattr__. With def __getattr__(self, n): return f'dyn:{n}', the property then silently returns 'dyn:_missing_internal' instead of failing. If __getattr__ raises AttributeError(f'no {n}'), the user sees AttributeError: no prop: the real missing name (undefined_attr) is lost and the property itself looks absent. Without __getattr__ the true error ('N' object has no attribute 'undefined_attr') is shown. This is common in proxy, ORM and config classes. Fix: make __getattr__ raise for names it does not handle (and never return defaults for everything), avoid AttributeError inside property bodies (catch and re-raise as RuntimeError), and debug with type(obj).prop.fget(obj). Verified on Python 3.11.13, 3.12.12, 3.13.11 and 3.14.7.
