Fix what I believe is a bug: when removing all previous handlers,

should copy the handlers list because it's being modified by the loop.
This commit is contained in:
Guido van Rossum 2002-12-20 01:54:21 +00:00
parent 328fff7214
commit 24475896dd
1 changed files with 2 additions and 2 deletions

View File

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