From d85f1c01afebd1db5d9400ba83b6d90e0819ce79 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Sun, 31 Jan 2010 22:33:22 +0000 Subject: [PATCH] Merged revisions 77892 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r77892 | victor.stinner | 2010-01-31 23:32:15 +0100 (dim., 31 janv. 2010) | 4 lines Issue #7819: Check sys.call_tracing() arguments types. py3k was already patched by issue #3661. ........ --- Lib/test/test_sys.py | 4 ++++ Misc/NEWS | 2 ++ Python/sysmodule.c | 2 +- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Lib/test/test_sys.py b/Lib/test/test_sys.py index 9589771542e..a8829849b86 100644 --- a/Lib/test/test_sys.py +++ b/Lib/test/test_sys.py @@ -391,6 +391,10 @@ class SysModuleTest(unittest.TestCase): out = p.stdout.read().strip() self.assertEqual(out, '?') + def test_call_tracing(self): + self.assertEqual(sys.call_tracing(str, (2,)), "2") + self.assertRaises(TypeError, sys.call_tracing, str, 2) + class SizeofTest(unittest.TestCase): diff --git a/Misc/NEWS b/Misc/NEWS index d299a68e20c..200764dd444 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -12,6 +12,8 @@ What's New in Python 2.6.5 Core and Builtins ----------------- +- Issue #7819: Check sys.call_tracing() arguments types. + - Issue #7788: Fix an interpreter crash produced by deleting a list slice with very large step value. diff --git a/Python/sysmodule.c b/Python/sysmodule.c index 10ba1cf668d..721f77da9ad 100644 --- a/Python/sysmodule.c +++ b/Python/sysmodule.c @@ -802,7 +802,7 @@ static PyObject * sys_call_tracing(PyObject *self, PyObject *args) { PyObject *func, *funcargs; - if (!PyArg_UnpackTuple(args, "call_tracing", 2, 2, &func, &funcargs)) + if (!PyArg_ParseTuple(args, "OO!:call_tracing", &func, &PyTuple_Type, &funcargs)) return NULL; return _PyEval_CallTracing(func, funcargs); }