This is a multi-part message in MIME format. ------=_NextPart_000_0016_01C343CA.2F1584A0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit [Alex Martelli] > ... > As I was checking that, I was struck by the fact that > having "write-only" settings is quite an anomaly -- > e.g. it makes writing a function that sets the check > interval to 0 temporarily, fiddles around a bit, then > sets it back to the previous value, a bit of trouble. > > Now that the check interval is a global variable, is > there any problem with making it readable (presumably > with a new sys.getcheckinterval() function) as well as > writable? Write-only settings are indeed strange. We could add a new function, or have setcheckinterval() return the old value. The attached patch implements the former. Guido, do you object to adding this to 2.3? I don't (the potential for breakage seems insignificant). ------=_NextPart_000_0016_01C343CA.2F1584A0 Content-Type: text/plain; name="getcheck.txt" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="getcheck.txt" Index: Doc/lib/libsys.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libsys.tex,v retrieving revision 1.65 diff -c -r1.65 libsys.tex *** Doc/lib/libsys.tex 2 Jul 2003 21:38:34 -0000 1.65 --- Doc/lib/libsys.tex 6 Jul 2003 18:21:43 -0000 *************** *** 197,202 **** --- 197,207 ---- or when \code{os._exit()} is called.} \end{datadesc} + \begin{funcdesc}{getcheckinterval}{} + Return the interpreter's ``check interval''; + see \function{setcheckinterval()}. + \end{funcdesc} + \begin{funcdesc}{getdefaultencoding}{} Return the name of the current default string encoding used by the Unicode implementation. Index: Lib/test/test_sys.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_sys.py,v retrieving revision 1.7 diff -c -r1.7 test_sys.py *** Lib/test/test_sys.py 1 May 2003 17:45:51 -0000 1.7 --- Lib/test/test_sys.py 6 Jul 2003 18:21:44 -0000 *************** *** 172,179 **** def test_setcheckinterval(self): self.assertRaises(TypeError, sys.setcheckinterval) ! sys.setcheckinterval(120) ! sys.setcheckinterval(100) def test_recursionlimit(self): self.assertRaises(TypeError, sys.getrecursionlimit, 42) --- 172,181 ---- def test_setcheckinterval(self): 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.assertEquals(sys.getcheckinterval(), n) def test_recursionlimit(self): self.assertRaises(TypeError, sys.getrecursionlimit, 42) Index: Misc/NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.808 diff -c -r1.808 NEWS *** Misc/NEWS 4 Jul 2003 04:40:44 -0000 1.808 --- Misc/NEWS 6 Jul 2003 18:21:46 -0000 *************** *** 10,15 **** --- 10,18 ---- Core and builtins ----------------- + - The new function sys.getcheckinterval() returns the last value set + by sys.setcheckinterval(). + - The Windows implementation of PyThread_start_new_thread() never checked error returns from Windows functions correctly. As a result, it could claim to start a new thread even when the Microsoft Index: Python/sysmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/sysmodule.c,v retrieving revision 2.119 diff -c -r2.119 sysmodule.c *** Python/sysmodule.c 10 May 2003 07:08:50 -0000 2.119 --- Python/sysmodule.c 6 Jul 2003 18:21:47 -0000 *************** *** 432,437 **** --- 432,447 ---- ); static PyObject * + sys_getcheckinterval(PyObject *self, PyObject *args) + { + return PyInt_FromLong(_Py_CheckInterval); + } + + PyDoc_STRVAR(getcheckinterval_doc, + "getcheckinterval() -> current check interval; see setcheckinterval()." + ); + + static PyObject * sys_setrecursionlimit(PyObject *self, PyObject *args) { int new_limit; *************** *** 723,728 **** --- 733,740 ---- #endif {"setcheckinterval", sys_setcheckinterval, METH_VARARGS, setcheckinterval_doc}, + {"getcheckinterval", sys_getcheckinterval, METH_NOARGS, + getcheckinterval_doc}, #ifdef HAVE_DLOPEN {"setdlopenflags", sys_setdlopenflags, METH_VARARGS, setdlopenflags_doc}, ------=_NextPart_000_0016_01C343CA.2F1584A0--
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4