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

Skip to content

Commit e2dffc0

Browse files
committed
#3663: extra DECREF on syntax errors.
Patch by Amaury Forgeot d'Arc, reviewed by Benjamin Peterson.
1 parent 2b9e040 commit e2dffc0

2 files changed

Lines changed: 6 additions & 1 deletion

File tree

Misc/NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ What's New in Python 3.0 release candidate 1
1212
Core and Builtins
1313
-----------------
1414

15+
- Issue #3663: Py_None was decref'd when printing SyntaxErrors.
16+
1517
- Issue #3657: Fix uninitialized memory read when pickling longs.
1618
Found by valgrind.
1719

Python/pythonrun.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1242,7 +1242,10 @@ PyErr_PrintEx(int set_sys_last_vars)
12421242
if (exception == NULL)
12431243
return;
12441244
PyErr_NormalizeException(&exception, &v, &tb);
1245-
tb = tb ? tb : Py_None;
1245+
if (tb == NULL) {
1246+
tb = Py_None;
1247+
Py_INCREF(tb);
1248+
}
12461249
PyException_SetTraceback(v, tb);
12471250
if (exception == NULL)
12481251
return;

0 commit comments

Comments
 (0)