mirror of
https://github.com/python/cpython.git
synced 2025-08-30 05:35:08 +00:00
bpo-37392: Remove sys.setcheckinterval() (GH-14355)
Remove sys.getcheckinterval() and sys.setcheckinterval() functions. They were deprecated since Python 3.2. Use sys.getswitchinterval() and sys.setswitchinterval() instead. Remove also check_interval field of the PyInterpreterState structure.
This commit is contained in:
parent
9fc720e5e4
commit
36456df138
9 changed files with 14 additions and 148 deletions
58
Python/clinic/sysmodule.c.h
generated
58
Python/clinic/sysmodule.c.h
generated
|
@ -281,62 +281,6 @@ sys_getprofile(PyObject *module, PyObject *Py_UNUSED(ignored))
|
|||
return sys_getprofile_impl(module);
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(sys_setcheckinterval__doc__,
|
||||
"setcheckinterval($module, n, /)\n"
|
||||
"--\n"
|
||||
"\n"
|
||||
"Set the async event check interval to n instructions.\n"
|
||||
"\n"
|
||||
"This tells the Python interpreter to check for asynchronous events\n"
|
||||
"every n instructions.\n"
|
||||
"\n"
|
||||
"This also affects how often thread switches occur.");
|
||||
|
||||
#define SYS_SETCHECKINTERVAL_METHODDEF \
|
||||
{"setcheckinterval", (PyCFunction)sys_setcheckinterval, METH_O, sys_setcheckinterval__doc__},
|
||||
|
||||
static PyObject *
|
||||
sys_setcheckinterval_impl(PyObject *module, int n);
|
||||
|
||||
static PyObject *
|
||||
sys_setcheckinterval(PyObject *module, PyObject *arg)
|
||||
{
|
||||
PyObject *return_value = NULL;
|
||||
int n;
|
||||
|
||||
if (PyFloat_Check(arg)) {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"integer argument expected, got float" );
|
||||
goto exit;
|
||||
}
|
||||
n = _PyLong_AsInt(arg);
|
||||
if (n == -1 && PyErr_Occurred()) {
|
||||
goto exit;
|
||||
}
|
||||
return_value = sys_setcheckinterval_impl(module, n);
|
||||
|
||||
exit:
|
||||
return return_value;
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(sys_getcheckinterval__doc__,
|
||||
"getcheckinterval($module, /)\n"
|
||||
"--\n"
|
||||
"\n"
|
||||
"Return the current check interval; see sys.setcheckinterval().");
|
||||
|
||||
#define SYS_GETCHECKINTERVAL_METHODDEF \
|
||||
{"getcheckinterval", (PyCFunction)sys_getcheckinterval, METH_NOARGS, sys_getcheckinterval__doc__},
|
||||
|
||||
static PyObject *
|
||||
sys_getcheckinterval_impl(PyObject *module);
|
||||
|
||||
static PyObject *
|
||||
sys_getcheckinterval(PyObject *module, PyObject *Py_UNUSED(ignored))
|
||||
{
|
||||
return sys_getcheckinterval_impl(module);
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(sys_setswitchinterval__doc__,
|
||||
"setswitchinterval($module, interval, /)\n"
|
||||
"--\n"
|
||||
|
@ -1082,4 +1026,4 @@ sys_getandroidapilevel(PyObject *module, PyObject *Py_UNUSED(ignored))
|
|||
#ifndef SYS_GETANDROIDAPILEVEL_METHODDEF
|
||||
#define SYS_GETANDROIDAPILEVEL_METHODDEF
|
||||
#endif /* !defined(SYS_GETANDROIDAPILEVEL_METHODDEF) */
|
||||
/*[clinic end generated code: output=43c4fde7b5783d8d input=a9049054013a1b77]*/
|
||||
/*[clinic end generated code: output=022614f3794666ae input=a9049054013a1b77]*/
|
||||
|
|
|
@ -203,7 +203,6 @@ PyInterpreterState_New(void)
|
|||
|
||||
memset(interp, 0, sizeof(*interp));
|
||||
interp->id_refcount = -1;
|
||||
interp->check_interval = 100;
|
||||
|
||||
PyStatus status = PyConfig_InitPythonConfig(&interp->config);
|
||||
if (_PyStatus_EXCEPTION(status)) {
|
||||
|
|
|
@ -1025,56 +1025,6 @@ sys_getprofile_impl(PyObject *module)
|
|||
return temp;
|
||||
}
|
||||
|
||||
/*[clinic input]
|
||||
sys.setcheckinterval
|
||||
|
||||
n: int
|
||||
/
|
||||
|
||||
Set the async event check interval to n instructions.
|
||||
|
||||
This tells the Python interpreter to check for asynchronous events
|
||||
every n instructions.
|
||||
|
||||
This also affects how often thread switches occur.
|
||||
[clinic start generated code]*/
|
||||
|
||||
static PyObject *
|
||||
sys_setcheckinterval_impl(PyObject *module, int n)
|
||||
/*[clinic end generated code: output=3f686cef07e6e178 input=7a35b17bf22a6227]*/
|
||||
{
|
||||
if (PyErr_WarnEx(PyExc_DeprecationWarning,
|
||||
"sys.getcheckinterval() and sys.setcheckinterval() "
|
||||
"are deprecated. Use sys.setswitchinterval() "
|
||||
"instead.", 1) < 0) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
PyThreadState *tstate = _PyThreadState_GET();
|
||||
tstate->interp->check_interval = n;
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
/*[clinic input]
|
||||
sys.getcheckinterval
|
||||
|
||||
Return the current check interval; see sys.setcheckinterval().
|
||||
[clinic start generated code]*/
|
||||
|
||||
static PyObject *
|
||||
sys_getcheckinterval_impl(PyObject *module)
|
||||
/*[clinic end generated code: output=1b5060bf2b23a47c input=4b6589cbcca1db4e]*/
|
||||
{
|
||||
if (PyErr_WarnEx(PyExc_DeprecationWarning,
|
||||
"sys.getcheckinterval() and sys.setcheckinterval() "
|
||||
"are deprecated. Use sys.getswitchinterval() "
|
||||
"instead.", 1) < 0) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
PyThreadState *tstate = _PyThreadState_GET();
|
||||
return PyLong_FromLong(tstate->interp->check_interval);
|
||||
}
|
||||
|
||||
/*[clinic input]
|
||||
sys.setswitchinterval
|
||||
|
@ -1990,8 +1940,6 @@ static PyMethodDef sys_methods[] = {
|
|||
SYS_INTERN_METHODDEF
|
||||
SYS_IS_FINALIZING_METHODDEF
|
||||
SYS_MDEBUG_METHODDEF
|
||||
SYS_SETCHECKINTERVAL_METHODDEF
|
||||
SYS_GETCHECKINTERVAL_METHODDEF
|
||||
SYS_SETSWITCHINTERVAL_METHODDEF
|
||||
SYS_GETSWITCHINTERVAL_METHODDEF
|
||||
SYS_SETDLOPENFLAGS_METHODDEF
|
||||
|
@ -2430,7 +2378,6 @@ getrefcount() -- return the reference count for an object (plus one :-)\n\
|
|||
getrecursionlimit() -- return the max recursion depth for the interpreter\n\
|
||||
getsizeof() -- return the size of an object in bytes\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\
|
||||
setrecursionlimit() -- set the max recursion depth for the interpreter\n\
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue