From a385c8159f6557beba501da6b56098641f149719 Mon Sep 17 00:00:00 2001 From: Reiase Date: Sat, 29 Nov 2025 19:07:06 +0800 Subject: [PATCH] fix: handle None depth value in probe function and ProbingTracer class --- python/probing/inspect/trace.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/python/probing/inspect/trace.py b/python/probing/inspect/trace.py index 4fa7e80..c6fe61a 100644 --- a/python/probing/inspect/trace.py +++ b/python/probing/inspect/trace.py @@ -610,8 +610,12 @@ def wrapper(*args, **kwargs): raise RuntimeError(f"Probe attributes not found for code id {code_id}") ProbingTracer = getattr(_trace_module, "ProbingTracer") + # Handle None depth value - use default of 1 if None + probe_depth = attrs.get("__probe_depth__", 1) + if probe_depth is None: + probe_depth = 1 tracer = ProbingTracer( - attrs.get("__probe_depth__", 1), + probe_depth, attrs.get("__probe_watch__", []), attrs.get("__probe_silent_watch__", []), ) @@ -678,6 +682,9 @@ def on_return(self): def _outof_depth(self): depth = self.count_calls - self.count_returns + # If self.depth is None, it means no depth limit, so we're never out of depth + if self.depth is None: + return False return depth > self.depth def _is_internal_frame(self, frame):