]> granicus.if.org Git - python/commitdiff
bpo-37392: Remove sys.setcheckinterval() (GH-14355)
authorVictor Stinner <vstinner@redhat.com>
Tue, 25 Jun 2019 01:01:08 +0000 (03:01 +0200)
committerGitHub <noreply@github.com>
Tue, 25 Jun 2019 01:01:08 +0000 (03:01 +0200)
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.

Doc/library/sys.rst
Doc/whatsnew/3.9.rst
Include/internal/pycore_pystate.h
Lib/test/test_sys.py
Misc/NEWS.d/next/Core and Builtins/2019-06-25-01-45-06.bpo-37392.J3JhIx.rst [new file with mode: 0644]
Python/clinic/sysmodule.c.h
Python/pystate.c
Python/sysmodule.c
Tools/ccbench/ccbench.py

index c073431c894817bc6a5940806077a8d582ff0f44..ea1f358d74294764b69fc7fe7a9c9addb7b3324e 100644 (file)
@@ -551,14 +551,6 @@ always available.
    .. versionadded:: 3.7
 
 
-.. function:: getcheckinterval()
-
-   Return the interpreter's "check interval"; see :func:`setcheckinterval`.
-
-   .. deprecated:: 3.2
-      Use :func:`getswitchinterval` instead.
-
-
 .. function:: getdefaultencoding()
 
    Return the name of the current default string encoding used by the Unicode
@@ -1141,21 +1133,6 @@ always available.
    implement a dynamic prompt.
 
 
-.. function:: setcheckinterval(interval)
-
-   Set the interpreter's "check interval".  This integer value determines how often
-   the interpreter checks for periodic things such as thread switches and signal
-   handlers.  The default is ``100``, meaning the check is performed every 100
-   Python virtual instructions. Setting it to a larger value may increase
-   performance for programs using threads.  Setting it to a value ``<=`` 0 checks
-   every virtual instruction, maximizing responsiveness as well as overhead.
-
-   .. deprecated:: 3.2
-      This function doesn't have an effect anymore, as the internal logic for
-      thread switching and asynchronous tasks has been rewritten.  Use
-      :func:`setswitchinterval` instead.
-
-
 .. function:: setdlopenflags(n)
 
    Set the flags used by the interpreter for :c:func:`dlopen` calls, such as when
index b625f271d128f8658c41852638ea2f1e19a5e304..95e12ff851ea5424c19b7d34e29747f587954750 100644 (file)
@@ -122,6 +122,11 @@ Deprecated
 Removed
 =======
 
+* The ``sys.getcheckinterval()`` and ``sys.setcheckinterval()`` functions have
+  been removed. They were deprecated since Python 3.2. Use
+  :func:`sys.getswitchinterval` and :func:`sys.setswitchinterval` instead.
+  (Contributed by Victor Stinner in :issue:`37392`.)
+
 * The C function ``PyImport_Cleanup()`` has been removed. It was documented as:
   "Empty the module table.  For internal use only."
   (Contributed by Victor Stinner in :issue:`36710`.)
index 68a72d8296877bc6ebe7612cf5c833a14862d062..0f92f67b977939872cbda576cd8e634f372cf16e 100644 (file)
@@ -82,9 +82,6 @@ struct _is {
     PyObject *builtins;
     PyObject *importlib;
 
-    /* Used in Python/sysmodule.c. */
-    int check_interval;
-
     /* Used in Modules/_threadmodule.c. */
     long num_threads;
     /* Support for runtime thread stack size tuning.
index 49f2722d95140ee3fd23f7b3392195a4bce77b87..c223f92ba6bb86f541f5b29b20741760c7e155df 100644 (file)
@@ -159,15 +159,6 @@ class SysModuleTest(unittest.TestCase):
     # testing sys.settrace() is done in test_sys_settrace.py
     # testing sys.setprofile() is done in test_sys_setprofile.py
 
-    def test_setcheckinterval(self):
-        with warnings.catch_warnings():
-            warnings.simplefilter("ignore")
-            self.assertRaises(TypeError, sys.setcheckinterval)
-            orig = sys.getcheckinterval()
-            for n in 0, 100, 120, orig: # orig last to restore starting state
-                sys.setcheckinterval(n)
-                self.assertEqual(sys.getcheckinterval(), n)
-
     def test_switchinterval(self):
         self.assertRaises(TypeError, sys.setswitchinterval)
         self.assertRaises(TypeError, sys.setswitchinterval, "a")
diff --git a/Misc/NEWS.d/next/Core and Builtins/2019-06-25-01-45-06.bpo-37392.J3JhIx.rst b/Misc/NEWS.d/next/Core and Builtins/2019-06-25-01-45-06.bpo-37392.J3JhIx.rst
new file mode 100644 (file)
index 0000000..97ab98c
--- /dev/null
@@ -0,0 +1,4 @@
+Remove ``sys.getcheckinterval()`` and ``sys.setcheckinterval()`` functions.
+They were deprecated since Python 3.2. Use :func:`sys.getswitchinterval` and
+:func:`sys.setswitchinterval` instead. Remove also ``check_interval`` field of
+the ``PyInterpreterState`` structure.
index 6f248ff18d9d7fb1decd5bf98a203820b53a10ae..4ddf5fee6e70c958e880ddf0531a53c6e06a25d0 100644 (file)
@@ -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]*/
index 503b4bf8549e8ab4433eeef381f63e6694ad8f75..1c3c0f44ed3f09613768e93db9a9441cf850d2ad 100644 (file)
@@ -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)) {
index d1a6c6a02618149d7b8724d4ec9c95c9a494a682..c9718d9f12ab9573fa5a50635dbf87f4fd7d8edf 100644 (file)
@@ -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\
index 60cec3e9cbefa2f46c18ef9921d96f6250618927..4f77a65f4d779ba34f659c2c87a7c6345aad01da 100644 (file)
@@ -541,10 +541,12 @@ def main():
                       help="run I/O bandwidth tests")
     parser.add_option("-i", "--interval",
                       action="store", type="int", dest="check_interval", default=None,
-                      help="sys.setcheckinterval() value")
+                      help="sys.setcheckinterval() value "
+                           "(Python 3.8 and older)")
     parser.add_option("-I", "--switch-interval",
                       action="store", type="float", dest="switch_interval", default=None,
-                      help="sys.setswitchinterval() value")
+                      help="sys.setswitchinterval() value "
+                           "(Python 3.2 and newer)")
     parser.add_option("-n", "--num-threads",
                       action="store", type="int", dest="nthreads", default=4,
                       help="max number of threads in tests")