From 8933521b3dec9a6ac55b91f2ff604528381a157c Mon Sep 17 00:00:00 2001 From: Antoine Pitrou Date: Sat, 23 Nov 2013 14:05:23 +0100 Subject: Fix refleak introduced by 4f730c045f5f (issue #18408) and unveiled by 95eea8624d05 (issue #16596). --- Python/ceval.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/Python/ceval.c b/Python/ceval.c index ab419dc..82f0651 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -3850,20 +3850,16 @@ call_exc_trace(Py_tracefunc func, PyObject *self, PyFrameObject *f) { PyObject *type, *value, *traceback, *orig_traceback, *arg; int err; - PyErr_Fetch(&type, &value, &traceback); + PyErr_Fetch(&type, &value, &orig_traceback); if (value == NULL) { value = Py_None; Py_INCREF(value); } - PyErr_NormalizeException(&type, &value, &traceback); - orig_traceback = traceback; - if (traceback == NULL) { - Py_INCREF(Py_None); - traceback = Py_None; - } + PyErr_NormalizeException(&type, &value, &orig_traceback); + traceback = (orig_traceback != NULL) ? orig_traceback : Py_None; arg = PyTuple_Pack(3, type, value, traceback); if (arg == NULL) { - PyErr_Restore(type, value, traceback); + PyErr_Restore(type, value, orig_traceback); return; } err = call_trace(func, self, f, PyTrace_EXCEPTION, arg); -- cgit v0.12