Unverified Commit 7467f2b3 authored by Lei Wang's avatar Lei Wang Committed by GitHub
Browse files

Resolve reference cycle. (#795)


Co-authored-by: default avatarHuanqi Cao <caohuanqi@deepseek.com>
parent bcfc8343
...@@ -40,8 +40,11 @@ def prim_func(func: Optional[Callable] = None, ...@@ -40,8 +40,11 @@ def prim_func(func: Optional[Callable] = None,
def decorator_wrapper(func): def decorator_wrapper(func):
if not inspect.isfunction(func): if not inspect.isfunction(func):
raise TypeError(f"Expect a function, but got: {func}") raise TypeError(f"Expect a function, but got: {func}")
nonlocal outer_stack
if utils.is_defined_in_class(outer_stack, func): if utils.is_defined_in_class(outer_stack, func):
outer_stack = None
return func return func
outer_stack = None
f = parse(func, utils.inspect_function_capture(func), check_well_formed=check_well_formed) f = parse(func, utils.inspect_function_capture(func), check_well_formed=check_well_formed)
setattr(f, "__name__", func.__name__) # noqa: B010 setattr(f, "__name__", func.__name__) # noqa: B010
return f return f
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment