Fix a regression added by some refactor.
This commit is contained in:
parent
e829de9792
commit
01a0031cf4
1 changed files with 19 additions and 6 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue