[Python-checkins] python/dist/src/Lib threading.py, 1.38, 1.39 traceback.py, 1.28, 1.29

nascheme at users.sourceforge.net nascheme at users.sourceforge.net
Wed Nov 5 18:03:03 EST 2003


Update of /cvsroot/python/python/dist/src/Lib
In directory sc8-pr-cvs1:/tmp/cvs-serv27582/Lib

Modified Files:
	threading.py traceback.py 
Log Message:
Add traceback.format_exc().


Index: threading.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/threading.py,v
retrieving revision 1.38
retrieving revision 1.39
diff -C2 -d -r1.38 -r1.39
*** threading.py	1 Jul 2003 20:01:55 -0000	1.38
--- threading.py	5 Nov 2003 23:02:59 -0000	1.39
***************
*** 9,15 ****
      raise
  
- from StringIO import StringIO as _StringIO
  from time import time as _time, sleep as _sleep
! from traceback import print_exc as _print_exc
  
  # Rename some stuff so "from threading import *" is safe
--- 9,14 ----
      raise
  
  from time import time as _time, sleep as _sleep
! from traceback import format_exc as _format_exc
  
  # Rename some stuff so "from threading import *" is safe
***************
*** 441,448 ****
                  if __debug__:
                      self._note("%s.__bootstrap(): unhandled exception", self)
-                 s = _StringIO()
-                 _print_exc(file=s)
                  _sys.stderr.write("Exception in thread %s:\n%s\n" %
!                                  (self.getName(), s.getvalue()))
              else:
                  if __debug__:
--- 440,445 ----
                  if __debug__:
                      self._note("%s.__bootstrap(): unhandled exception", self)
                  _sys.stderr.write("Exception in thread %s:\n%s\n" %
!                                   (self.getName(), _format_exc()))
              else:
                  if __debug__:

Index: traceback.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/traceback.py,v
retrieving revision 1.28
retrieving revision 1.29
diff -C2 -d -r1.28 -r1.29
*** traceback.py	15 Aug 2002 14:59:00 -0000	1.28
--- traceback.py	5 Nov 2003 23:03:00 -0000	1.29
***************
*** 7,12 ****
  __all__ = ['extract_stack', 'extract_tb', 'format_exception',
             'format_exception_only', 'format_list', 'format_stack',
!            'format_tb', 'print_exc', 'print_exception', 'print_last',
!            'print_stack', 'print_tb', 'tb_lineno']
  
  def _print(file, str='', terminator='\n'):
--- 7,12 ----
  __all__ = ['extract_stack', 'extract_tb', 'format_exception',
             'format_exception_only', 'format_list', 'format_stack',
!            'format_tb', 'print_exc', 'format_exc', 'print_exception',
!            'print_last', 'print_stack', 'print_tb', 'tb_lineno']
  
  def _print(file, str='', terminator='\n'):
***************
*** 211,214 ****
--- 211,224 ----
      finally:
          etype = value = tb = None
+ 
+ 
+ def format_exc(limit=None):
+     """Like print_exc() but return a string."""
+     try:
+         etype, value, tb = sys.exc_info()
+         return ''.join(format_exception(etype, value, tb, limit))
+     finally:
+         etype = value = tb = None
+     
  
  def print_last(limit=None, file=None):





More information about the Python-checkins mailing list