diff --git a/src/uberjob/_util/traceback.py b/src/uberjob/_util/traceback.py index 5e7a1f4..9c7d641 100644 --- a/src/uberjob/_util/traceback.py +++ b/src/uberjob/_util/traceback.py @@ -48,10 +48,18 @@ def __repr__(self): ) +TruncatedStackFrame = None + + class TruncatedStackFrameType: def __repr__(self): return "TruncatedStackFrame" + def __new__(cls, *args, **kwargs): + if TruncatedStackFrame is not None: + return TruncatedStackFrame + return super().__new__(cls, *args, **kwargs) + TruncatedStackFrame = TruncatedStackFrameType() @@ -81,7 +89,7 @@ def recurse(frame, depth): def render_symbolic_traceback(stack_frame): stack_frames = [] while stack_frame: - if type(stack_frame) is TruncatedStackFrameType: + if stack_frame is TruncatedStackFrame: stack_frames.append(stack_frame) break if "/IPython/core/" in stack_frame.path: @@ -90,7 +98,7 @@ def render_symbolic_traceback(stack_frame): stack_frame = stack_frame.outer def format_stack_frame(s): - if type(s) is TruncatedStackFrameType: + if s is TruncatedStackFrame: return " ... truncated" return f' File "{s.path}", line {s.line}, in {s.name}'