Skip to content

Commit bde9635

Browse files
committed
Fix traceback in threads when SetTrace used.
Testing === The following script returns normamly, where previously it encountered: `ValueError: call stack is not deep enough`. ``` import sys import threading import typing def tracer(frame, event, arg): return tracer def do_check(): isinstance(None, typing.Iterable) sys.settrace(tracer) t = threading.Thread(target=do_check) t.start() t.join() ```
1 parent 3ef134b commit bde9635

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

src/core/IronPython/Runtime/PythonContext.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3848,9 +3848,9 @@ public PythonTracebackListenersDispatcher(PythonContext parent) {
38483848
void Debugging.ITraceCallback.OnTraceEvent(Debugging.TraceEventKind kind, string name, string sourceFileName, SourceSpan sourceSpan, Func<IDictionary<object, object>> scopeCallback, object payload, object customPayload) {
38493849
var listener = _parent._tracebackListeners.Value;
38503850

3851-
if (listener == null && _parent.PythonOptions.Tracing) {
3852-
// If tracing without sys.set_trace() is enabled, we need to register a dummy traceback listener,
3853-
// because of the FunctionStack handling done there.
3851+
if (listener == null && (_parent.PythonOptions.Tracing || _parent._tracebackListenersCount > 0)) {
3852+
// If tracing is enabled (globally or via SetTrace on any thread), we need to register a dummy
3853+
// traceback listener for this thread, because of the FunctionStack handling done there.
38543854
_parent._tracebackListeners.Value = listener = new PythonTracebackListener(_parent, null);
38553855
}
38563856

0 commit comments

Comments
 (0)