Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 8ec25b4

Browse files
committed
If sys.trace is None, don't trace. For exceptions, only use
the local trace function.
1 parent 6d80647 commit 8ec25b4

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

Python/ceval.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,10 @@ eval_code(co, globals, locals, arg)
159159

160160
trace = sysget("trace");
161161
if (trace != NULL) {
162+
if (trace == None) {
163+
trace = NULL;
164+
}
165+
else {
162166
/* sys.trace, if defined, is a function that will
163167
be called on *every* entry to a code block.
164168
Its return value, if not None, is a function that
@@ -184,6 +188,7 @@ eval_code(co, globals, locals, arg)
184188
DECREF(trace);
185189
trace = NULL;
186190
}
191+
}
187192
}
188193

189194
next_instr = GETUSTRINGVALUE(f->f_code->co_code);
@@ -1057,11 +1062,7 @@ eval_code(co, globals, locals, arg)
10571062
f->f_lasti -= 2;
10581063
tb_here(f);
10591064

1060-
if (trace)
1061-
v = trace;
1062-
else
1063-
v = sysget("trace");
1064-
if (v) {
1065+
if (trace) {
10651066
object *type, *value, *traceback, *arg;
10661067
err_get(&type, &value);
10671068
traceback = tb_fetch();
@@ -1073,7 +1074,7 @@ eval_code(co, globals, locals, arg)
10731074
settupleitem(arg, 1, value);
10741075
settupleitem(arg, 2, traceback);
10751076
}
1076-
v = call_trace(v, f, "exception", arg);
1077+
v = call_trace(trace, f, "exception", arg);
10771078
if (v == NULL) {
10781079
/* Trace function raised error */
10791080
tb_here(f);

0 commit comments

Comments
 (0)