From 9fa9f05e5db54004e3484fa3388fc180034927dc Mon Sep 17 00:00:00 2001 From: William FH <13333726+hinthornw@users.noreply.github.com> Date: Fri, 26 Apr 2024 19:31:55 -0700 Subject: [PATCH] Catch System Error in ast parse (#20961) I can't seem to reproduce, but i got this: ``` SystemError: AST constructor recursion depth mismatch (before=102, after=37) ``` And the operation isn't critical for the actual forward pass so seems preferable to expand our caught exceptions --- libs/core/langchain_core/runnables/utils.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libs/core/langchain_core/runnables/utils.py b/libs/core/langchain_core/runnables/utils.py index d5553e786f..9e960fb4c7 100644 --- a/libs/core/langchain_core/runnables/utils.py +++ b/libs/core/langchain_core/runnables/utils.py @@ -218,7 +218,7 @@ def get_function_first_arg_dict_keys(func: Callable) -> Optional[List[str]]: visitor = IsFunctionArgDict() visitor.visit(tree) return list(visitor.keys) if visitor.keys else None - except (SyntaxError, TypeError, OSError): + except (SyntaxError, TypeError, OSError, SystemError): return None @@ -241,7 +241,7 @@ def get_lambda_source(func: Callable) -> Optional[str]: visitor = GetLambdaSource() visitor.visit(tree) return visitor.source if visitor.count == 1 else name - except (SyntaxError, TypeError, OSError): + except (SyntaxError, TypeError, OSError, SystemError): return name @@ -270,7 +270,7 @@ def get_function_nonlocals(func: Callable) -> List[Any]: else: values.append(vv) return values - except (SyntaxError, TypeError, OSError): + except (SyntaxError, TypeError, OSError, SystemError): return []