From: Victor Stinner Date: Sun, 31 Jan 2010 22:32:15 +0000 (+0000) Subject: Issue #7819: Check sys.call_tracing() arguments types. X-Git-Tag: v2.7a3~46 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b4b0a2935db54457f6876f1991905cc9b4fce6e9;p=python Issue #7819: Check sys.call_tracing() arguments types. py3k was already patched by issue #3661. --- diff --git a/Lib/test/test_sys.py b/Lib/test/test_sys.py index f58d90063f..6b45d127eb 100644 --- a/Lib/test/test_sys.py +++ b/Lib/test/test_sys.py @@ -433,6 +433,10 @@ class SysModuleTest(unittest.TestCase): out = p.communicate()[0].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 5f64b8a8e1..6b0f121e90 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -12,6 +12,8 @@ What's New in Python 2.7 alpha 3? 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 3a991970cf..65a9d8f934 100644 --- a/Python/sysmodule.c +++ b/Python/sysmodule.c @@ -840,7 +840,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); }