[Python-checkins] python/dist/src/Lib/logging __init__.py, 1.24.2.1, 1.24.2.2

vsajip@users.sourceforge.net vsajip at users.sourceforge.net
Fri Sep 16 12:44:44 CEST 2005


Update of /cvsroot/python/python/dist/src/Lib/logging
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8350

Modified Files:
      Tag: release24-maint
	__init__.py 
Log Message:
Misc. backported changes

Index: __init__.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/logging/__init__.py,v
retrieving revision 1.24.2.1
retrieving revision 1.24.2.2
diff -u -d -r1.24.2.1 -r1.24.2.2
--- __init__.py	31 Mar 2005 20:10:38 -0000	1.24.2.1
+++ __init__.py	16 Sep 2005 10:44:40 -0000	1.24.2.2
@@ -52,7 +52,9 @@
 # _srcfile is used when walking the stack to check when we've got the first
 # caller stack frame.
 #
-if string.lower(__file__[-4:]) in ['.pyc', '.pyo']:
+if hasattr(sys, 'frozen'): #support for py2exe
+    _srcfile = "logging%s__init__%s" % (os.sep, __file__[-4:])
+elif string.lower(__file__[-4:]) in ['.pyc', '.pyo']:
     _srcfile = __file__[:-4] + '.py'
 else:
     _srcfile = __file__
@@ -542,6 +544,7 @@
 #---------------------------------------------------------------------------
 
 _handlers = {}  #repository of handlers (for flushing when shutdown called)
+_handlerList = [] # added to allow handlers to be removed in reverse of order initialized
 
 class Handler(Filterer):
     """
@@ -564,6 +567,7 @@
         _acquireLock()
         try:    #unlikely to raise an exception, but you never know...
             _handlers[self] = 1
+            _handlerList.insert(0, self)
         finally:
             _releaseLock()
         self.createLock()
@@ -666,6 +670,7 @@
         _acquireLock()
         try:    #unlikely to raise an exception, but you never know...
             del _handlers[self]
+            _handlerList.remove(self)
         finally:
             _releaseLock()
 
@@ -1085,7 +1090,11 @@
         """
         if hdlr in self.handlers:
             #hdlr.close()
-            self.handlers.remove(hdlr)
+            hdlr.acquire()
+            try:
+                self.handlers.remove(hdlr)
+            finally:
+                hdlr.release()
 
     def callHandlers(self, record):
         """
@@ -1305,7 +1314,7 @@
 
     Should be called at application exit.
     """
-    for h in _handlers.keys():
+    for h in _handlerList[:]: # was _handlers.keys():
         #errors might occur, for example, if files are locked
         #we just ignore them
         try:



More information about the Python-checkins mailing list