[CMF-checkins] CVS: CMF/CMFCore - DirectoryView.py:1.12 MembershipTool.py:1.15

Tres Seaver tseaver@zope.com
Wed, 24 Oct 2001 08:59:31 -0400


Update of /cvs-repository/CMF/CMFCore
In directory cvs.zope.org:/tmp/cvs-serv5435/CMFCore

Modified Files:
	DirectoryView.py MembershipTool.py 
Log Message:


  - Modified error-logging code to avoid potential leaks of
    traceback frame


=== CMF/CMFCore/DirectoryView.py 1.11 => 1.12 ===
                 import sys, traceback
                 type,value,tb = sys.exc_info()
-                LOG( 'DirectoryView'
-                   , ERROR
-                   , 'Error during prepareContents:'
-                   , traceback.format_exception( type, value, tb )
-                   )
+                try:
+                    LOG( 'DirectoryView'
+                    , ERROR
+                    , 'Error during prepareContents:'
+                    , traceback.format_exception( type, value, tb )
+                    )
+                finally:
+                    tb = None       # Avoid leaking frame
                 self.data = {}
                 self.objects = ()
                     
@@ -243,13 +246,19 @@
                         from zLOG import LOG, ERROR
                         import sys, traceback
                         typ, val, tb = sys.exc_info()
-                        exc_lines = traceback.format_exception( typ, val, tb )
-                        LOG( 'DirectoryView', ERROR, join( exc_lines, '\n' ) )
-                        ob = BadFile( name
-                                    , e_filepath
-                                    , exc_str=join( exc_lines, '\r\n' )
-                                    , fullname=entry
-                                    )
+                        try:
+                            exc_lines = traceback.format_exception( typ
+                                                                  , val
+                                                                  , tb )
+                            LOG( 'DirectoryView', ERROR
+                               , join( exc_lines, '\n' ) )
+                            ob = BadFile( name
+                                        , e_filepath
+                                        , exc_str=join( exc_lines, '\r\n' )
+                                        , fullname=entry
+                                        )
+                        finally:
+                            tb = None   # Avoid leaking frame!
                     ob_id = ob.getId()
                     data[ob_id] = ob
                     objects.append({'id': ob_id, 'meta_type': ob.meta_type})


=== CMF/CMFCore/MembershipTool.py 1.14 => 1.15 ===
                 import sys
                 type,value,tb = sys.exc_info()
-                LOG('CMFCore.MembershipTool',
-                    ERROR,
-                    'Error during wrapUser:',
-                    "\nType:%s\nValue:%s\n" % (type,value))
+                try:
+                    LOG('CMFCore.MembershipTool',
+                        ERROR,
+                        'Error during wrapUser:',
+                        "\nType:%s\nValue:%s\n" % (type,value))
+                finally:
+                    tb = None       # Avoid leaking frame
                 pass
         # Failed.
         return u