Fix a regression added by some refactor.

This commit is contained in:
Yaro Kasear 2025-10-20 13:53:27 -05:00
parent e829de9792
commit 01a0031cf4

View file

@ -40,14 +40,27 @@ def _safe_get_loaded_attr(obj, name):
if st is None:
return None
try:
attrs = getattr(st, "attrs", {}).get(name)
if attrs is not None and name in attrs:
attr = attrs[name]
val = attr.loaded_value
return None if val is NO_VALUE else val
st_dict = getattr(st, "dict", {})
if name in st_dict:
return st_dict.get(name)
return st_dict[name]
attrs = getattr(st, "attrs", None)
attr = None
if attrs is not None:
try:
attr = attrs[name]
except Exception:
try:
get = getattr(attrs, "get", None)
if callable(get):
attr = get(name)
except Exception:
attr = None
if attr is not None:
val = attr.loaded_value
return None if val is NO_VALUE else val
return None
except Exception:
return None