From: Antoine Pitrou Date: Tue, 26 Aug 2008 22:02:58 +0000 (+0000) Subject: #3663: extra DECREF on syntax errors. X-Git-Tag: v3.0rc1~166 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e2dffc0aeb6e03d8e6512a13cb3fe05562f7c655;p=python #3663: extra DECREF on syntax errors. Patch by Amaury Forgeot d'Arc, reviewed by Benjamin Peterson. --- diff --git a/Misc/NEWS b/Misc/NEWS index d779132422..2d91cb1e01 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -12,6 +12,8 @@ What's New in Python 3.0 release candidate 1 Core and Builtins ----------------- +- Issue #3663: Py_None was decref'd when printing SyntaxErrors. + - Issue #3657: Fix uninitialized memory read when pickling longs. Found by valgrind. diff --git a/Python/pythonrun.c b/Python/pythonrun.c index 1ee062fe6f..39c86e749f 100644 --- a/Python/pythonrun.c +++ b/Python/pythonrun.c @@ -1242,7 +1242,10 @@ PyErr_PrintEx(int set_sys_last_vars) if (exception == NULL) return; PyErr_NormalizeException(&exception, &v, &tb); - tb = tb ? tb : Py_None; + if (tb == NULL) { + tb = Py_None; + Py_INCREF(tb); + } PyException_SetTraceback(v, tb); if (exception == NULL) return;