Merge pull request #14560 from Nuullll/condfunc-warning
Handle CondFunc exception when resolving attributes
This commit is contained in:
commit
30aa5e0a7c
|
@ -11,10 +11,14 @@ class CondFunc:
|
||||||
break
|
break
|
||||||
except ImportError:
|
except ImportError:
|
||||||
pass
|
pass
|
||||||
for attr_name in func_path[i:-1]:
|
try:
|
||||||
resolved_obj = getattr(resolved_obj, attr_name)
|
for attr_name in func_path[i:-1]:
|
||||||
orig_func = getattr(resolved_obj, func_path[-1])
|
resolved_obj = getattr(resolved_obj, attr_name)
|
||||||
setattr(resolved_obj, func_path[-1], lambda *args, **kwargs: self(*args, **kwargs))
|
orig_func = getattr(resolved_obj, func_path[-1])
|
||||||
|
setattr(resolved_obj, func_path[-1], lambda *args, **kwargs: self(*args, **kwargs))
|
||||||
|
except AttributeError:
|
||||||
|
print(f"Warning: Failed to resolve {orig_func} for CondFunc hijack")
|
||||||
|
pass
|
||||||
self.__init__(orig_func, sub_func, cond_func)
|
self.__init__(orig_func, sub_func, cond_func)
|
||||||
return lambda *args, **kwargs: self(*args, **kwargs)
|
return lambda *args, **kwargs: self(*args, **kwargs)
|
||||||
def __init__(self, orig_func, sub_func, cond_func):
|
def __init__(self, orig_func, sub_func, cond_func):
|
||||||
|
|
Loading…
Reference in New Issue