diff options
| author | Neal Norwitz <nnorwitz@gmail.com> | 2002-03-03 15:12:58 +0000 |
|---|---|---|
| committer | Neal Norwitz <nnorwitz@gmail.com> | 2002-03-03 15:12:58 +0000 |
| commit | 290d31e2fc02a0d887da2c76fbe4e72377442a0a (patch) | |
| tree | 5871169da82f3b2b5504ad07b3490260de501fb0 | |
| parent | 54e0eabc2d3343c1ab71f5fb90fdda2f06b606e1 (diff) | |
| download | cpython-git-290d31e2fc02a0d887da2c76fbe4e72377442a0a.tar.gz | |
SF #506611, fix sys.setprofile(), sys.settrace() core dumps
when no arguments are passed
| -rw-r--r-- | Lib/test/test_profilehooks.py | 6 | ||||
| -rw-r--r-- | Lib/test/test_scope.py | 4 | ||||
| -rw-r--r-- | Python/sysmodule.c | 4 |
3 files changed, 12 insertions, 2 deletions
diff --git a/Lib/test/test_profilehooks.py b/Lib/test/test_profilehooks.py index cc97df8dc4..fa38d3047c 100644 --- a/Lib/test/test_profilehooks.py +++ b/Lib/test/test_profilehooks.py @@ -1,5 +1,7 @@ from __future__ import generators +from test_support import TestFailed + import pprint import sys import unittest @@ -329,6 +331,10 @@ protect_ident = ident(protect) def capture_events(callable, p=None): + try: sys.setprofile() + except TypeError: pass + else: raise TestFailed, 'sys.setprofile() did not raise TypeError' + if p is None: p = HookWatcher() sys.setprofile(p.callback) diff --git a/Lib/test/test_scope.py b/Lib/test/test_scope.py index bb29f8b9a7..85cfed4749 100644 --- a/Lib/test/test_scope.py +++ b/Lib/test/test_scope.py @@ -471,6 +471,10 @@ sys.settrace(tracer) adaptgetter("foo", TestClass, (1, "")) sys.settrace(None) +try: sys.settrace() +except TypeError: pass +else: raise TestFailed, 'sys.settrace() did not raise TypeError' + print "20. eval and exec with free variables" def f(x): diff --git a/Python/sysmodule.c b/Python/sysmodule.c index 90338dea35..3448e6a9d3 100644 --- a/Python/sysmodule.c +++ b/Python/sysmodule.c @@ -564,10 +564,10 @@ static PyMethodDef sys_methods[] = { {"setdlopenflags", sys_setdlopenflags, METH_VARARGS, setdlopenflags_doc}, #endif - {"setprofile", sys_setprofile, METH_OLDARGS, setprofile_doc}, + {"setprofile", sys_setprofile, METH_O, setprofile_doc}, {"setrecursionlimit", sys_setrecursionlimit, METH_VARARGS, setrecursionlimit_doc}, - {"settrace", sys_settrace, METH_OLDARGS, settrace_doc}, + {"settrace", sys_settrace, METH_O, settrace_doc}, {NULL, NULL} /* sentinel */ }; |
