[Python-3000-checkins] r55639 - in python/branches/p3yk: Demo/pdist/cvslock.py Doc/lib/libsys.tex Doc/lib/libtypes.tex Doc/ref/ref3.tex Lib/SocketServer.py Lib/logging/__init__.py Lib/plat-mac/cfmfile.py Lib/test/test_inspect.py Lib/test/test_traceback.py Misc/NEWS Misc/cheatsheet Python/ceval.c Python/import.c

neal.norwitz python-3000-checkins at python.org
Tue May 29 09:58:23 CEST 2007


Author: neal.norwitz
Date: Tue May 29 09:58:11 2007
New Revision: 55639

Modified:
   python/branches/p3yk/Demo/pdist/cvslock.py
   python/branches/p3yk/Doc/lib/libsys.tex
   python/branches/p3yk/Doc/lib/libtypes.tex
   python/branches/p3yk/Doc/ref/ref3.tex
   python/branches/p3yk/Lib/SocketServer.py
   python/branches/p3yk/Lib/logging/__init__.py
   python/branches/p3yk/Lib/plat-mac/cfmfile.py
   python/branches/p3yk/Lib/test/test_inspect.py
   python/branches/p3yk/Lib/test/test_traceback.py
   python/branches/p3yk/Misc/NEWS
   python/branches/p3yk/Misc/cheatsheet
   python/branches/p3yk/Python/ceval.c
   python/branches/p3yk/Python/import.c
Log:
Remove sys.exc_{type,exc_value,exc_traceback}

Modified: python/branches/p3yk/Demo/pdist/cvslock.py
==============================================================================
--- python/branches/p3yk/Demo/pdist/cvslock.py	(original)
+++ python/branches/p3yk/Demo/pdist/cvslock.py	Tue May 29 09:58:11 2007
@@ -262,7 +262,6 @@
         rl.unlock()
     finally:
         print [1]
-        sys.exc_traceback = None
         print [2]
         if rl:
             rl.unlock()

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 09:58:11 2007
@@ -168,17 +168,6 @@
 \versionadded{2.3}
 \end{funcdesc}
 
-\begin{datadesc}{exc_type}
-\dataline{exc_value}
-\dataline{exc_traceback}
-\deprecated {1.5}
-            {Use \function{exc_info()} instead.}
-  Since they are global variables, they are not specific to the
-  current thread, so their use is not safe in a multi-threaded
-  program.  When no exception is being handled, \code{exc_type} is set
-  to \code{None} and the other two are undefined.
-\end{datadesc}
-
 \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/lib/libtypes.tex
==============================================================================
--- python/branches/p3yk/Doc/lib/libtypes.tex	(original)
+++ python/branches/p3yk/Doc/lib/libtypes.tex	Tue May 29 09:58:11 2007
@@ -163,7 +163,7 @@
 
 \begin{datadesc}{TracebackType}
 The type of traceback objects such as found in
-\code{sys.exc_traceback}.
+\code{sys.exc_info()[2]}.
 \end{datadesc}
 
 \begin{datadesc}{FrameType}

Modified: python/branches/p3yk/Doc/ref/ref3.tex
==============================================================================
--- python/branches/p3yk/Doc/ref/ref3.tex	(original)
+++ python/branches/p3yk/Doc/ref/ref3.tex	Tue May 29 09:58:11 2007
@@ -977,10 +977,8 @@
 traceback.  When an exception handler is entered, the stack trace is
 made available to the program.
 (See section~\ref{try}, ``The \code{try} statement.'')
-It is accessible as \code{sys.exc_traceback}, and also as the third
-item of the tuple returned by \code{sys.exc_info()}.  The latter is
-the preferred interface, since it works correctly when the program is
-using multiple threads.
+It is accessible as the third
+item of the tuple returned by \code{sys.exc_info()}.
 When the program contains no suitable handler, the stack trace is written
 (nicely formatted) to the standard error stream; if the interpreter is
 interactive, it is also made available to the user as
@@ -994,7 +992,6 @@
   \ttindex{exc_traceback}
   \ttindex{last_traceback}}
 \ttindex{sys.exc_info}
-\ttindex{sys.exc_traceback}
 \ttindex{sys.last_traceback}
 
 Special read-only attributes: \member{tb_next} is the next level in the
@@ -1198,13 +1195,13 @@
 references between objects (e.g., a doubly-linked list or a tree data
 structure with parent and child pointers); a reference to the object
 on the stack frame of a function that caught an exception (the
-traceback stored in \code{sys.exc_traceback} keeps the stack frame
+traceback stored in \code{sys.exc_info()[2]} keeps the stack frame
 alive); or a reference to the object on the stack frame that raised an
 unhandled exception in interactive mode (the traceback stored in
 \code{sys.last_traceback} keeps the stack frame alive).  The first
 situation can only be remedied by explicitly breaking the cycles; the
 latter two situations can be resolved by storing \code{None} in
-\code{sys.exc_traceback} or \code{sys.last_traceback}.  Circular
+\code{sys.last_traceback}.  Circular
 references which are garbage are detected when the option cycle
 detector is enabled (it's on by default), but can only be cleaned up
 if there are no Python-level \method{__del__()} methods involved.

Modified: python/branches/p3yk/Lib/SocketServer.py
==============================================================================
--- python/branches/p3yk/Lib/SocketServer.py	(original)
+++ python/branches/p3yk/Lib/SocketServer.py	Tue May 29 09:58:11 2007
@@ -518,12 +518,9 @@
         self.request = request
         self.client_address = client_address
         self.server = server
-        try:
-            self.setup()
-            self.handle()
-            self.finish()
-        finally:
-            sys.exc_traceback = None    # Help garbage collection
+        self.setup()
+        self.handle()
+        self.finish()
 
     def setup(self):
         pass

Modified: python/branches/p3yk/Lib/logging/__init__.py
==============================================================================
--- python/branches/p3yk/Lib/logging/__init__.py	(original)
+++ python/branches/p3yk/Lib/logging/__init__.py	Tue May 29 09:58:11 2007
@@ -66,7 +66,7 @@
     try:
         raise Exception
     except:
-        return sys.exc_traceback.tb_frame.f_back
+        return sys.exc_info()[2].tb_frame.f_back
 
 if hasattr(sys, '_getframe'): currentframe = lambda: sys._getframe(3)
 # done filching

Modified: python/branches/p3yk/Lib/plat-mac/cfmfile.py
==============================================================================
--- python/branches/p3yk/Lib/plat-mac/cfmfile.py	(original)
+++ python/branches/p3yk/Lib/plat-mac/cfmfile.py	Tue May 29 09:58:11 2007
@@ -68,7 +68,7 @@
                 try:
                     data = Res.Get1Resource('cfrg', 0).data
                 except Res.Error:
-                    raise Res.Error, "no 'cfrg' resource found", sys.exc_traceback
+                    raise Res.Error, "no 'cfrg' resource found", sys.exc_info()[2]
             finally:
                 Res.CloseResFile(resref)
                 Res.UseResFile(currentresref)

Modified: python/branches/p3yk/Lib/test/test_inspect.py
==============================================================================
--- python/branches/p3yk/Lib/test/test_inspect.py	(original)
+++ python/branches/p3yk/Lib/test/test_inspect.py	Tue May 29 09:58:11 2007
@@ -25,7 +25,7 @@
 try:
     1/0
 except:
-    tb = sys.exc_traceback
+    tb = sys.exc_info()[2]
 
 git = mod.StupidGit()
 

Modified: python/branches/p3yk/Lib/test/test_traceback.py
==============================================================================
--- python/branches/p3yk/Lib/test/test_traceback.py	(original)
+++ python/branches/p3yk/Lib/test/test_traceback.py	Tue May 29 09:58:11 2007
@@ -72,7 +72,7 @@
                 test_bug737473.test()
             except ValueError:
                 # this loads source code to linecache
-                traceback.extract_tb(sys.exc_traceback)
+                traceback.extract_tb(sys.exc_info()[2])
 
             # If this test runs too quickly, test_bug737473.py's mtime
             # attribute will remain unchanged even if the file is rewritten.
@@ -89,7 +89,7 @@
             try:
                 test_bug737473.test()
             except NotImplementedError:
-                src = traceback.extract_tb(sys.exc_traceback)[-1][-1]
+                src = traceback.extract_tb(sys.exc_info()[2])[-1][-1]
                 self.failUnlessEqual(src, 'raise NotImplementedError')
         finally:
             sys.path[:] = savedpath
@@ -103,7 +103,7 @@
             1/0
         except:
             import sys
-            sys.exc_traceback.__members__
+            sys.exc_info()[2].__members__
 
     def test_base_exception(self):
         # Test that exceptions derived from BaseException are formatted right

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

Modified: python/branches/p3yk/Misc/cheatsheet
==============================================================================
--- python/branches/p3yk/Misc/cheatsheet	(original)
+++ python/branches/p3yk/Misc/cheatsheet	Tue May 29 09:58:11 2007
@@ -1315,10 +1315,6 @@
                      in C that are linked into this interpreter.
 check_interval       How often to check for thread switches or signals(measured
                      in number of virtual machine instructions)
-exc_type, exc_value, Deprecated since release 1.5. Use exc_info() instead.
-exc_traceback
-exitfunc             User can set to a parameterless fcn. It will getcalled
-                     before interpreter exits.
 last_type,           Set only when an exception not handled andinterpreter
 last_value,          prints an error. Used by debuggers.
 last_traceback
@@ -1351,7 +1347,7 @@
 setprofile(func)   Sets a profile function for performance profiling.
                    Info on exception currently being handled; this is atuple
                    (exc_type, exc_value, exc_traceback).Warning: assigning the
-exc_info()         traceback return value to a loca variable in a
+exc_info()         traceback return value to a local variable in a
                    function handling an exception will cause a circular
                    reference.
 setdefaultencoding Change default Unicode encoding - defaults to 7-bit ASCII.

Modified: python/branches/p3yk/Python/ceval.c
==============================================================================
--- python/branches/p3yk/Python/ceval.c	(original)
+++ python/branches/p3yk/Python/ceval.c	Tue May 29 09:58:11 2007
@@ -2941,10 +2941,6 @@
 	Py_XDECREF(tmp_type);
 	Py_XDECREF(tmp_value);
 	Py_XDECREF(tmp_tb);
-	/* For b/w compatibility */
-	PySys_SetObject("exc_type", type);
-	PySys_SetObject("exc_value", value);
-	PySys_SetObject("exc_traceback", tb);
 }
 
 static void
@@ -2975,11 +2971,6 @@
 	Py_XDECREF(tmp_value);
 	Py_XDECREF(tmp_tb);
 
-	/* For b/w compatibility */
-	PySys_SetObject("exc_type", frame->f_exc_type);
-	PySys_SetObject("exc_value", frame->f_exc_value);
-	PySys_SetObject("exc_traceback", frame->f_exc_traceback);
-
 	/* Clear the frame's exception info. */
 	tmp_type = frame->f_exc_type;
 	tmp_value = frame->f_exc_value;

Modified: python/branches/p3yk/Python/import.c
==============================================================================
--- python/branches/p3yk/Python/import.c	(original)
+++ python/branches/p3yk/Python/import.c	Tue May 29 09:58:11 2007
@@ -371,7 +371,6 @@
 /* List of names to clear in sys */
 static char* sys_deletes[] = {
 	"path", "argv", "ps1", "ps2",
-	"exc_type", "exc_value", "exc_traceback",
 	"last_type", "last_value", "last_traceback",
 	"path_hooks", "path_importer_cache", "meta_path",
 	NULL


More information about the Python-3000-checkins mailing list