[Python-3000-checkins] r55643 - in python/branches/p3yk: Doc/lib/libsys.tex Doc/tut/tut.tex Lib/test/test_sys.py Misc/NEWS Python/sysmodule.c

neal.norwitz python-3000-checkins at python.org
Tue May 29 10:18:29 CEST 2007


Author: neal.norwitz
Date: Tue May 29 10:18:19 2007
New Revision: 55643

Modified:
   python/branches/p3yk/Doc/lib/libsys.tex
   python/branches/p3yk/Doc/tut/tut.tex
   python/branches/p3yk/Lib/test/test_sys.py
   python/branches/p3yk/Misc/NEWS
   python/branches/p3yk/Python/sysmodule.c
Log:
Remove sys.exc_clear()

Modified: python/branches/p3yk/Doc/lib/libsys.tex
==============================================================================
--- python/branches/p3yk/Doc/lib/libsys.tex	(original)
+++ python/branches/p3yk/Doc/lib/libsys.tex	Tue May 29 10:18:19 2007
@@ -132,11 +132,6 @@
   encapsulates the call stack at the point where the exception
   originally occurred.  \obindex{traceback}
 
-  If \function{exc_clear()} is called, this function will return three
-  \code{None} values until either another exception is raised in the
-  current thread or the execution stack returns to a frame where
-  another exception is being handled.
-
   \warning{Assigning the \var{traceback} return value to a
   local variable in a function that is handling an exception will
   cause a circular reference.  This will prevent anything referenced
@@ -153,21 +148,6 @@
   efficient to avoid creating cycles.}
 \end{funcdesc}
 
-\begin{funcdesc}{exc_clear}{}
-  This function clears all information relating to the current or last
-  exception that occurred in the current thread.  After calling this
-  function, \function{exc_info()} will return three \code{None} values until
-  another exception is raised in the current thread or the execution stack
-  returns to a frame where another exception is being handled.
-
-  This function is only needed in only a few obscure situations.  These
-  include logging and error handling systems that report information on the
-  last or current exception.  This function can also be used to try to free
-  resources and trigger object finalization, though no guarantee is made as
-  to what objects will be freed, if any.
-\versionadded{2.3}
-\end{funcdesc}
-
 \begin{datadesc}{exec_prefix}
   A string giving the site-specific directory prefix where the
   platform-dependent Python files are installed; by default, this is

Modified: python/branches/p3yk/Doc/tut/tut.tex
==============================================================================
--- python/branches/p3yk/Doc/tut/tut.tex	(original)
+++ python/branches/p3yk/Doc/tut/tut.tex	Tue May 29 10:18:19 2007
@@ -2653,7 +2653,7 @@
 ['__displayhook__', '__doc__', '__excepthook__', '__name__', '__stderr__',
  '__stdin__', '__stdout__', '_getframe', 'api_version', 'argv', 
  'builtin_module_names', 'byteorder', 'callstats', 'copyright',
- 'displayhook', 'exc_clear', 'exc_info', 'excepthook',
+ 'displayhook', 'exc_info', 'excepthook',
  'exec_prefix', 'executable', 'exit', 'getdefaultencoding', 'getdlopenflags',
  'getrecursionlimit', 'getrefcount', 'hexversion', 'maxint', 'maxunicode',
  'meta_path', 'modules', 'path', 'path_hooks', 'path_importer_cache',

Modified: python/branches/p3yk/Lib/test/test_sys.py
==============================================================================
--- python/branches/p3yk/Lib/test/test_sys.py	(original)
+++ python/branches/p3yk/Lib/test/test_sys.py	Tue May 29 10:18:19 2007
@@ -63,47 +63,6 @@
     # FIXME: testing the code for a lost or replaced excepthook in
     # Python/pythonrun.c::PyErr_PrintEx() is tricky.
 
-    def test_exc_clear(self):
-        self.assertRaises(TypeError, sys.exc_clear, 42)
-
-        # Verify that exc_info is present and matches exc, then clear it, and
-        # check that it worked.
-        def clear_check(exc):
-            typ, value, traceback = sys.exc_info()
-            self.assert_(typ is not None)
-            self.assert_(value is exc)
-            self.assert_(traceback is not None)
-
-            sys.exc_clear()
-
-            typ, value, traceback = sys.exc_info()
-            self.assert_(typ is None)
-            self.assert_(value is None)
-            self.assert_(traceback is None)
-
-        def clear():
-            try:
-                raise ValueError, 42
-            except ValueError as exc:
-                clear_check(exc)
-
-        # Raise an exception and check that it can be cleared
-        clear()
-
-        # Verify that a frame currently handling an exception is
-        # unaffected by calling exc_clear in a nested frame.
-        try:
-            raise ValueError, 13
-        except ValueError as exc:
-            typ1, value1, traceback1 = sys.exc_info()
-            clear()
-            typ2, value2, traceback2 = sys.exc_info()
-
-            self.assert_(typ1 is typ2)
-            self.assert_(value1 is exc)
-            self.assert_(value1 is value2)
-            self.assert_(traceback1 is traceback2)
-
     def test_exit(self):
         self.assertRaises(TypeError, sys.exit, 42, 42)
 

Modified: python/branches/p3yk/Misc/NEWS
==============================================================================
--- python/branches/p3yk/Misc/NEWS	(original)
+++ python/branches/p3yk/Misc/NEWS	Tue May 29 10:18:19 2007
@@ -163,7 +163,7 @@
 
 - Removed these attributes from Python modules:
   * operator module: div, idiv, __div__, __idiv__, isCallable, sequenceIncludes
-  * sys module: exc_type, exc_value, exc_traceback
+  * sys module: exc_clear(), exc_type, exc_value, exc_traceback
 
 
 Library

Modified: python/branches/p3yk/Python/sysmodule.c
==============================================================================
--- python/branches/p3yk/Python/sysmodule.c	(original)
+++ python/branches/p3yk/Python/sysmodule.c	Tue May 29 10:18:19 2007
@@ -163,33 +163,6 @@
 );
 
 static PyObject *
-sys_exc_clear(PyObject *self, PyObject *noargs)
-{
-	PyThreadState *tstate = PyThreadState_GET();
-	PyObject *tmp_type, *tmp_value, *tmp_tb;
-	tmp_type = tstate->exc_type;
-	tmp_value = tstate->exc_value;
-	tmp_tb = tstate->exc_traceback;
-	tstate->exc_type = NULL;
-	tstate->exc_value = NULL;
-	tstate->exc_traceback = NULL;
-	Py_XDECREF(tmp_type);
-	Py_XDECREF(tmp_value);
-	Py_XDECREF(tmp_tb);
-	Py_INCREF(Py_None);
-	return Py_None;
-}
-
-PyDoc_STRVAR(exc_clear_doc,
-"exc_clear() -> None\n\
-\n\
-Clear global information on the current exception.  Subsequent calls to\n\
-exc_info() will return (None,None,None) until another exception is raised\n\
-in the current thread or the execution stack returns to a frame where\n\
-another exception is being handled."
-);
-
-static PyObject *
 sys_exit(PyObject *self, PyObject *args)
 {
 	PyObject *exit_code = 0;
@@ -760,7 +733,6 @@
 	 current_frames_doc},
 	{"displayhook",	sys_displayhook, METH_O, displayhook_doc},
 	{"exc_info",	sys_exc_info, METH_NOARGS, exc_info_doc},
-	{"exc_clear",	sys_exc_clear, METH_NOARGS, exc_clear_doc},
 	{"excepthook",	sys_excepthook, METH_VARARGS, excepthook_doc},
 	{"exit",	sys_exit, METH_VARARGS, exit_doc},
 #ifdef Py_USING_UNICODE
@@ -948,7 +920,6 @@
 displayhook() -- print an object to the screen, and save it in __builtin__._\n\
 excepthook() -- print an exception and its traceback to sys.stderr\n\
 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\
 getrefcount() -- return the reference count for an object (plus one :-)\n\


More information about the Python-3000-checkins mailing list