mirror of
https://github.com/python/cpython.git
synced 2025-07-19 09:15:34 +00:00
gh-117764: Add signatures for some functions in the sys module (GH-117770)
Use Argument Clinic if possible.
This commit is contained in:
parent
6e05537676
commit
2638c28be0
2 changed files with 73 additions and 35 deletions
34
Python/clinic/sysmodule.c.h
generated
34
Python/clinic/sysmodule.c.h
generated
|
@ -323,8 +323,20 @@ exit:
|
||||||
return return_value;
|
return return_value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PyDoc_STRVAR(sys_settrace__doc__,
|
||||||
|
"settrace($module, function, /)\n"
|
||||||
|
"--\n"
|
||||||
|
"\n"
|
||||||
|
"Set the global debug tracing function.\n"
|
||||||
|
"\n"
|
||||||
|
"It will be called on each function call. See the debugger chapter\n"
|
||||||
|
"in the library manual.");
|
||||||
|
|
||||||
|
#define SYS_SETTRACE_METHODDEF \
|
||||||
|
{"settrace", (PyCFunction)sys_settrace, METH_O, sys_settrace__doc__},
|
||||||
|
|
||||||
PyDoc_STRVAR(sys__settraceallthreads__doc__,
|
PyDoc_STRVAR(sys__settraceallthreads__doc__,
|
||||||
"_settraceallthreads($module, arg, /)\n"
|
"_settraceallthreads($module, function, /)\n"
|
||||||
"--\n"
|
"--\n"
|
||||||
"\n"
|
"\n"
|
||||||
"Set the global debug tracing function in all running threads belonging to the current interpreter.\n"
|
"Set the global debug tracing function in all running threads belonging to the current interpreter.\n"
|
||||||
|
@ -355,14 +367,26 @@ sys_gettrace(PyObject *module, PyObject *Py_UNUSED(ignored))
|
||||||
return sys_gettrace_impl(module);
|
return sys_gettrace_impl(module);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PyDoc_STRVAR(sys_setprofile__doc__,
|
||||||
|
"setprofile($module, function, /)\n"
|
||||||
|
"--\n"
|
||||||
|
"\n"
|
||||||
|
"Set the profiling function.\n"
|
||||||
|
"\n"
|
||||||
|
"It will be called on each function call and return. See the profiler\n"
|
||||||
|
"chapter in the library manual.");
|
||||||
|
|
||||||
|
#define SYS_SETPROFILE_METHODDEF \
|
||||||
|
{"setprofile", (PyCFunction)sys_setprofile, METH_O, sys_setprofile__doc__},
|
||||||
|
|
||||||
PyDoc_STRVAR(sys__setprofileallthreads__doc__,
|
PyDoc_STRVAR(sys__setprofileallthreads__doc__,
|
||||||
"_setprofileallthreads($module, arg, /)\n"
|
"_setprofileallthreads($module, function, /)\n"
|
||||||
"--\n"
|
"--\n"
|
||||||
"\n"
|
"\n"
|
||||||
"Set the profiling function in all running threads belonging to the current interpreter.\n"
|
"Set the profiling function in all running threads belonging to the current interpreter.\n"
|
||||||
"\n"
|
"\n"
|
||||||
"It will be called on each function call and return. See the profiler chapter\n"
|
"It will be called on each function call and return. See the profiler\n"
|
||||||
"in the library manual.");
|
"chapter in the library manual.");
|
||||||
|
|
||||||
#define SYS__SETPROFILEALLTHREADS_METHODDEF \
|
#define SYS__SETPROFILEALLTHREADS_METHODDEF \
|
||||||
{"_setprofileallthreads", (PyCFunction)sys__setprofileallthreads, METH_O, sys__setprofileallthreads__doc__},
|
{"_setprofileallthreads", (PyCFunction)sys__setprofileallthreads, METH_O, sys__setprofileallthreads__doc__},
|
||||||
|
@ -1504,4 +1528,4 @@ exit:
|
||||||
#ifndef SYS_GETANDROIDAPILEVEL_METHODDEF
|
#ifndef SYS_GETANDROIDAPILEVEL_METHODDEF
|
||||||
#define SYS_GETANDROIDAPILEVEL_METHODDEF
|
#define SYS_GETANDROIDAPILEVEL_METHODDEF
|
||||||
#endif /* !defined(SYS_GETANDROIDAPILEVEL_METHODDEF) */
|
#endif /* !defined(SYS_GETANDROIDAPILEVEL_METHODDEF) */
|
||||||
/*[clinic end generated code: output=b8b1c53e04c3b20c input=a9049054013a1b77]*/
|
/*[clinic end generated code: output=518424ee03e353b0 input=a9049054013a1b77]*/
|
||||||
|
|
|
@ -500,7 +500,8 @@ sys_addaudithook_impl(PyObject *module, PyObject *hook)
|
||||||
}
|
}
|
||||||
|
|
||||||
PyDoc_STRVAR(audit_doc,
|
PyDoc_STRVAR(audit_doc,
|
||||||
"audit(event, *args)\n\
|
"audit($module, event, /, *args)\n\
|
||||||
|
--\n\
|
||||||
\n\
|
\n\
|
||||||
Passes the event to any audit hooks that are attached.");
|
Passes the event to any audit hooks that are attached.");
|
||||||
|
|
||||||
|
@ -644,7 +645,8 @@ sys_breakpointhook(PyObject *self, PyObject *const *args, Py_ssize_t nargs, PyOb
|
||||||
}
|
}
|
||||||
|
|
||||||
PyDoc_STRVAR(breakpointhook_doc,
|
PyDoc_STRVAR(breakpointhook_doc,
|
||||||
"breakpointhook(*args, **kws)\n"
|
"breakpointhook($module, /, *args, **kwargs)\n"
|
||||||
|
"--\n"
|
||||||
"\n"
|
"\n"
|
||||||
"This hook function is called by built-in breakpoint().\n"
|
"This hook function is called by built-in breakpoint().\n"
|
||||||
);
|
);
|
||||||
|
@ -1085,34 +1087,40 @@ trace_trampoline(PyObject *self, PyFrameObject *frame,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*[clinic input]
|
||||||
|
sys.settrace
|
||||||
|
|
||||||
|
function: object
|
||||||
|
/
|
||||||
|
|
||||||
|
Set the global debug tracing function.
|
||||||
|
|
||||||
|
It will be called on each function call. See the debugger chapter
|
||||||
|
in the library manual.
|
||||||
|
[clinic start generated code]*/
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
sys_settrace(PyObject *self, PyObject *args)
|
sys_settrace(PyObject *module, PyObject *function)
|
||||||
|
/*[clinic end generated code: output=999d12e9d6ec4678 input=8107feb01c5f1c4e]*/
|
||||||
{
|
{
|
||||||
PyThreadState *tstate = _PyThreadState_GET();
|
PyThreadState *tstate = _PyThreadState_GET();
|
||||||
if (args == Py_None) {
|
if (function == Py_None) {
|
||||||
if (_PyEval_SetTrace(tstate, NULL, NULL) < 0) {
|
if (_PyEval_SetTrace(tstate, NULL, NULL) < 0) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (_PyEval_SetTrace(tstate, trace_trampoline, args) < 0) {
|
if (_PyEval_SetTrace(tstate, trace_trampoline, function) < 0) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Py_RETURN_NONE;
|
Py_RETURN_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
PyDoc_STRVAR(settrace_doc,
|
|
||||||
"settrace(function)\n\
|
|
||||||
\n\
|
|
||||||
Set the global debug tracing function. It will be called on each\n\
|
|
||||||
function call. See the debugger chapter in the library manual."
|
|
||||||
);
|
|
||||||
|
|
||||||
/*[clinic input]
|
/*[clinic input]
|
||||||
sys._settraceallthreads
|
sys._settraceallthreads
|
||||||
|
|
||||||
arg: object
|
function as arg: object
|
||||||
/
|
/
|
||||||
|
|
||||||
Set the global debug tracing function in all running threads belonging to the current interpreter.
|
Set the global debug tracing function in all running threads belonging to the current interpreter.
|
||||||
|
@ -1123,7 +1131,7 @@ in the library manual.
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
sys__settraceallthreads(PyObject *module, PyObject *arg)
|
sys__settraceallthreads(PyObject *module, PyObject *arg)
|
||||||
/*[clinic end generated code: output=161cca30207bf3ca input=5906aa1485a50289]*/
|
/*[clinic end generated code: output=161cca30207bf3ca input=d4bde1f810d73675]*/
|
||||||
{
|
{
|
||||||
PyObject* argument = NULL;
|
PyObject* argument = NULL;
|
||||||
Py_tracefunc func = NULL;
|
Py_tracefunc func = NULL;
|
||||||
|
@ -1159,45 +1167,51 @@ sys_gettrace_impl(PyObject *module)
|
||||||
return Py_NewRef(temp);
|
return Py_NewRef(temp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*[clinic input]
|
||||||
|
sys.setprofile
|
||||||
|
|
||||||
|
function: object
|
||||||
|
/
|
||||||
|
|
||||||
|
Set the profiling function.
|
||||||
|
|
||||||
|
It will be called on each function call and return. See the profiler
|
||||||
|
chapter in the library manual.
|
||||||
|
[clinic start generated code]*/
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
sys_setprofile(PyObject *self, PyObject *args)
|
sys_setprofile(PyObject *module, PyObject *function)
|
||||||
|
/*[clinic end generated code: output=1c3503105939db9c input=055d0d7961413a62]*/
|
||||||
{
|
{
|
||||||
PyThreadState *tstate = _PyThreadState_GET();
|
PyThreadState *tstate = _PyThreadState_GET();
|
||||||
if (args == Py_None) {
|
if (function == Py_None) {
|
||||||
if (_PyEval_SetProfile(tstate, NULL, NULL) < 0) {
|
if (_PyEval_SetProfile(tstate, NULL, NULL) < 0) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (_PyEval_SetProfile(tstate, profile_trampoline, args) < 0) {
|
if (_PyEval_SetProfile(tstate, profile_trampoline, function) < 0) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Py_RETURN_NONE;
|
Py_RETURN_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
PyDoc_STRVAR(setprofile_doc,
|
|
||||||
"setprofile(function)\n\
|
|
||||||
\n\
|
|
||||||
Set the profiling function. It will be called on each function call\n\
|
|
||||||
and return. See the profiler chapter in the library manual."
|
|
||||||
);
|
|
||||||
|
|
||||||
/*[clinic input]
|
/*[clinic input]
|
||||||
sys._setprofileallthreads
|
sys._setprofileallthreads
|
||||||
|
|
||||||
arg: object
|
function as arg: object
|
||||||
/
|
/
|
||||||
|
|
||||||
Set the profiling function in all running threads belonging to the current interpreter.
|
Set the profiling function in all running threads belonging to the current interpreter.
|
||||||
|
|
||||||
It will be called on each function call and return. See the profiler chapter
|
It will be called on each function call and return. See the profiler
|
||||||
in the library manual.
|
chapter in the library manual.
|
||||||
[clinic start generated code]*/
|
[clinic start generated code]*/
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
sys__setprofileallthreads(PyObject *module, PyObject *arg)
|
sys__setprofileallthreads(PyObject *module, PyObject *arg)
|
||||||
/*[clinic end generated code: output=2d61319e27b309fe input=d1a356d3f4f9060a]*/
|
/*[clinic end generated code: output=2d61319e27b309fe input=a10589439ba20cee]*/
|
||||||
{
|
{
|
||||||
PyObject* argument = NULL;
|
PyObject* argument = NULL;
|
||||||
Py_tracefunc func = NULL;
|
Py_tracefunc func = NULL;
|
||||||
|
@ -2525,11 +2539,11 @@ static PyMethodDef sys_methods[] = {
|
||||||
SYS_SETSWITCHINTERVAL_METHODDEF
|
SYS_SETSWITCHINTERVAL_METHODDEF
|
||||||
SYS_GETSWITCHINTERVAL_METHODDEF
|
SYS_GETSWITCHINTERVAL_METHODDEF
|
||||||
SYS_SETDLOPENFLAGS_METHODDEF
|
SYS_SETDLOPENFLAGS_METHODDEF
|
||||||
{"setprofile", sys_setprofile, METH_O, setprofile_doc},
|
SYS_SETPROFILE_METHODDEF
|
||||||
SYS__SETPROFILEALLTHREADS_METHODDEF
|
SYS__SETPROFILEALLTHREADS_METHODDEF
|
||||||
SYS_GETPROFILE_METHODDEF
|
SYS_GETPROFILE_METHODDEF
|
||||||
SYS_SETRECURSIONLIMIT_METHODDEF
|
SYS_SETRECURSIONLIMIT_METHODDEF
|
||||||
{"settrace", sys_settrace, METH_O, settrace_doc},
|
SYS_SETTRACE_METHODDEF
|
||||||
SYS__SETTRACEALLTHREADS_METHODDEF
|
SYS__SETTRACEALLTHREADS_METHODDEF
|
||||||
SYS_GETTRACE_METHODDEF
|
SYS_GETTRACE_METHODDEF
|
||||||
SYS_CALL_TRACING_METHODDEF
|
SYS_CALL_TRACING_METHODDEF
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue