summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2008-01-20 13:59:46 (GMT)
committerGeorg Brandl <georg@python.org>2008-01-20 13:59:46 (GMT)
commit56112895d69131ee4f34d4e3e9406614313df57f (patch)
treeb57e176cd54df7984553c6337390ce1712fb2292 /Python
parent92058d29334fcb4d01ae2ab7c165aba2ef6da2af (diff)
downloadcpython-56112895d69131ee4f34d4e3e9406614313df57f.zip
cpython-56112895d69131ee4f34d4e3e9406614313df57f.tar.gz
cpython-56112895d69131ee4f34d4e3e9406614313df57f.tar.bz2
#1648: add sys.gettrace() and sys.getprofile().
Diffstat (limited to 'Python')
-rw-r--r--Python/sysmodule.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/Python/sysmodule.c b/Python/sysmodule.c
index bbcd957..12ad828 100644
--- a/Python/sysmodule.c
+++ b/Python/sysmodule.c
@@ -398,6 +398,25 @@ function call. See the debugger chapter in the library manual."
);
static PyObject *
+sys_gettrace(PyObject *self, PyObject *args)
+{
+ PyThreadState *tstate = PyThreadState_GET();
+ PyObject *temp = tstate->c_traceobj;
+
+ if (temp == NULL)
+ temp = Py_None;
+ Py_INCREF(temp);
+ return temp;
+}
+
+PyDoc_STRVAR(gettrace_doc,
+"gettrace()\n\
+\n\
+Return the global debug tracing function set with sys.settrace.\n\
+See the debugger chapter in the library manual."
+);
+
+static PyObject *
sys_setprofile(PyObject *self, PyObject *args)
{
if (trace_init() == -1)
@@ -418,6 +437,25 @@ and return. See the profiler chapter in the library manual."
);
static PyObject *
+sys_getprofile(PyObject *self, PyObject *args)
+{
+ PyThreadState *tstate = PyThreadState_GET();
+ PyObject *temp = tstate->c_profileobj;
+
+ if (temp == NULL)
+ temp = Py_None;
+ Py_INCREF(temp);
+ return temp;
+}
+
+PyDoc_STRVAR(getprofile_doc,
+"getprofile()\n\
+\n\
+Return the profiling function set with sys.setprofile.\n\
+See the profiler chapter in the library manual."
+);
+
+static PyObject *
sys_setcheckinterval(PyObject *self, PyObject *args)
{
if (!PyArg_ParseTuple(args, "i:setcheckinterval", &_Py_CheckInterval))
@@ -793,12 +831,14 @@ static PyMethodDef sys_methods[] = {
setdlopenflags_doc},
#endif
{"setprofile", sys_setprofile, METH_O, setprofile_doc},
+ {"getprofile", sys_getprofile, METH_NOARGS, getprofile_doc},
{"setrecursionlimit", sys_setrecursionlimit, METH_VARARGS,
setrecursionlimit_doc},
#ifdef WITH_TSC
{"settscdump", sys_settscdump, METH_VARARGS, settscdump_doc},
#endif
{"settrace", sys_settrace, METH_O, settrace_doc},
+ {"gettrace", sys_gettrace, METH_NOARGS, gettrace_doc},
{"call_tracing", sys_call_tracing, METH_VARARGS, call_tracing_doc},
{NULL, NULL} /* sentinel */
};
@@ -941,8 +981,10 @@ exc_info() -- return thread-safe information about the current exception\n\
exc_clear() -- clear the exception state for the current thread\n\
exit() -- exit the interpreter by raising SystemExit\n\
getdlopenflags() -- returns flags to be used for dlopen() calls\n\
+getprofile() -- get the global profiling function\n\
getrefcount() -- return the reference count for an object (plus one :-)\n\
getrecursionlimit() -- return the max recursion depth for the interpreter\n\
+gettrace() -- get the global debug tracing function\n\
setcheckinterval() -- control how often the interpreter checks for events\n\
setdlopenflags() -- set the flags to be used for dlopen() calls\n\
setprofile() -- set the global profiling function\n\