]> granicus.if.org Git - python/commitdiff
Fix what I believe is a bug: when removing all previous handlers,
authorGuido van Rossum <guido@python.org>
Fri, 20 Dec 2002 01:54:21 +0000 (01:54 +0000)
committerGuido van Rossum <guido@python.org>
Fri, 20 Dec 2002 01:54:21 +0000 (01:54 +0000)
should copy the handlers list because it's being modified by the loop.

Lib/logging/config.py

index 3d342f413d5946a7918730312953b9b7a0ab697e..933bdc7afc3c02d1f04338676616533b8721511e 100644 (file)
@@ -133,7 +133,7 @@ def fileConfig(fname, defaults=None):
             if "level" in opts:
                 level = cp.get(sectname, "level")
                 log.setLevel(logging._levelNames[level])
-            for h in root.handlers:
+            for h in root.handlers[:]:
                 root.removeHandler(h)
             hlist = cp.get(sectname, "handlers")
             if len(hlist):
@@ -165,7 +165,7 @@ def fileConfig(fname, defaults=None):
                 if "level" in opts:
                     level = cp.get(sectname, "level")
                     logger.setLevel(logging._levelNames[level])
-                for h in logger.handlers:
+                for h in logger.handlers[:]:
                     logger.removeHandler(h)
                 logger.propagate = propagate
                 logger.disabled = 0