use safe_hasattr instead of simple attribute access.