Skip to content

Commit 30aa5e0

Browse files
Merge pull request #14560 from Nuullll/condfunc-warning
Handle CondFunc exception when resolving attributes
2 parents cab1d83 + ec9acb3 commit 30aa5e0

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

modules/sd_hijack_utils.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,14 @@ def __new__(cls, orig_func, sub_func, cond_func):
1111
break
1212
except ImportError:
1313
pass
14-
for attr_name in func_path[i:-1]:
15-
resolved_obj = getattr(resolved_obj, attr_name)
16-
orig_func = getattr(resolved_obj, func_path[-1])
17-
setattr(resolved_obj, func_path[-1], lambda *args, **kwargs: self(*args, **kwargs))
14+
try:
15+
for attr_name in func_path[i:-1]:
16+
resolved_obj = getattr(resolved_obj, attr_name)
17+
orig_func = getattr(resolved_obj, func_path[-1])
18+
setattr(resolved_obj, func_path[-1], lambda *args, **kwargs: self(*args, **kwargs))
19+
except AttributeError:
20+
print(f"Warning: Failed to resolve {orig_func} for CondFunc hijack")
21+
pass
1822
self.__init__(orig_func, sub_func, cond_func)
1923
return lambda *args, **kwargs: self(*args, **kwargs)
2024
def __init__(self, orig_func, sub_func, cond_func):

0 commit comments

Comments
 (0)