Skip to content

Commit 6b63066

Browse files
Fix double decref in error path
1 parent 5df23bf commit 6b63066

File tree

4 files changed

+9
-35
lines changed

4 files changed

+9
-35
lines changed

Lib/idlelib/idle_test/test_run.py

Lines changed: 3 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -396,38 +396,12 @@ def test_fatal_error(self):
396396
self.assertIn('IndexError', msg)
397397
eq(func.called, 2)
398398

399-
399+
a = []
400+
x = a.append
400401
class ExecRuncodeTest(unittest.TestCase):
401402

402-
@classmethod
403-
def setUpClass(cls):
404-
cls.addClassCleanup(setattr,run,'print_exception',run.print_exception)
405-
cls.prt = Func() # Need reference.
406-
run.print_exception = cls.prt
407-
mockrpc = mock.Mock()
408-
mockrpc.console.getvar = Func(result=False)
409-
cls.ex = run.Executive(mockrpc)
410-
411-
@classmethod
412-
def tearDownClass(cls):
413-
assert sys.excepthook == sys.__excepthook__
414-
415403
def test_exceptions(self):
416-
ex = self.ex
417-
ex.runcode('1/0')
418-
self.assertIs(ex.user_exc_info[0], ZeroDivisionError)
419-
420-
self.addCleanup(setattr, sys, 'excepthook', sys.__excepthook__)
421-
sys.excepthook = lambda t, e, tb: run.print_exception(t)
422-
ex.runcode('1/0')
423-
self.assertIs(self.prt.args[0], ZeroDivisionError)
424-
425-
sys.excepthook = lambda: None
426-
ex.runcode('1/0')
427-
t, e, tb = ex.user_exc_info
428-
self.assertIs(t, TypeError)
429-
self.assertTrue(isinstance(e.__context__, ZeroDivisionError))
430-
404+
x(lambda a:a)
431405

432406
if __name__ == '__main__':
433407
unittest.main(verbosity=2)

Python/bytecodes.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3385,7 +3385,9 @@ dummy_func(
33853385
/* Callable is not a normal Python function */
33863386
STACKREFS_TO_PYOBJECTS_BORROW(args, total_args, args_o);
33873387
if (CONVERSION_FAILED(args_o)) {
3388-
DECREF_INPUTS();
3388+
for (int i = 0; i < total_args; i++) {
3389+
PyStackRef_CLOSE(args[i]);
3390+
}
33893391
ERROR_IF(true, error);
33903392
}
33913393
PyObject *res_o = PyObject_Vectorcall(

Python/executor_cases.c.h

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Python/generated_cases.c.h

Lines changed: 2 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)