Skip to content

Commit eee3fd4

Browse files
committed
(Hopefully) fix bug in reference count in call_exc_trace()
plus minor rearrangements found during debugging
1 parent e765f7d commit eee3fd4

1 file changed

Lines changed: 7 additions & 12 deletions

File tree

Python/ceval.c

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/***********************************************************
2-
Copyright 1991 by Stichting Mathematisch Centrum, Amsterdam, The
2+
Copyright 1991, 1992 by Stichting Mathematisch Centrum, Amsterdam, The
33
Netherlands.
44
55
All Rights Reserved
@@ -1106,7 +1106,6 @@ eval_code(co, globals, locals, arg)
11061106
sysset("exc_traceback", v);
11071107
sysset("exc_value", val);
11081108
sysset("exc_type", exc);
1109-
err_clear();
11101109
}
11111110
PUSH(v);
11121111
PUSH(val);
@@ -1192,21 +1191,19 @@ call_exc_trace(p_trace, p_newtrace, f)
11921191
err_get(&type, &value);
11931192
traceback = tb_fetch();
11941193
arg = newtupleobject(3);
1195-
if (arg == NULL) {
1196-
err = -1;
1194+
if (arg == NULL)
11971195
goto cleanup;
1198-
}
11991196
settupleitem(arg, 0, type);
12001197
settupleitem(arg, 1, value);
12011198
settupleitem(arg, 2, traceback);
12021199
err = call_trace(p_trace, p_newtrace, f, "exception", arg);
1203-
XDECREF(arg);
1204-
cleanup:
12051200
if (!err) {
1201+
cleanup:
12061202
/* Restore original exception */
12071203
err_setval(type, value);
12081204
tb_store(traceback);
12091205
}
1206+
XDECREF(arg);
12101207
}
12111208

12121209
static int
@@ -1254,12 +1251,13 @@ call_trace(p_trace, p_newtrace, f, msg, arg)
12541251
if (res == NULL) {
12551252
/* The trace proc raised an exception */
12561253
tb_here(f);
1257-
XDECREF(*p_trace);
1254+
DECREF(*p_trace);
12581255
*p_trace = NULL;
12591256
if (p_newtrace) {
12601257
XDECREF(*p_newtrace);
12611258
*p_newtrace = NULL;
12621259
}
1260+
return -1;
12631261
}
12641262
else {
12651263
if (p_newtrace) {
@@ -1272,11 +1270,8 @@ call_trace(p_trace, p_newtrace, f, msg, arg)
12721270
}
12731271
}
12741272
DECREF(res);
1275-
}
1276-
if (res == NULL)
1277-
return -1;
1278-
else
12791273
return 0;
1274+
}
12801275
}
12811276

12821277
object *

0 commit comments

Comments
 (0)