StdoutCapture: Browse weakref only if they actually are weakrefs.

master
Valentin Lorentz 2013-08-26 00:22:22 +02:00
parent 63cd704006
commit bce6dd4302
1 changed files with 3 additions and 3 deletions

View File

@ -31,6 +31,7 @@
import sys import sys
import json import json
import logging import logging
import weakref
import supybot.utils as utils import supybot.utils as utils
from supybot.commands import * from supybot.commands import *
@ -68,9 +69,8 @@ class StdoutCapture(callbacks.Plugin):
sys.stderr = self.StdoutBuffer(sys.stderr) sys.stderr = self.StdoutBuffer(sys.stderr)
# I'm being a bit evil here. # I'm being a bit evil here.
for logger in logging._handlerList: for logger in logging._handlerList:
if isinstance(logger, StdoutBuffer): if isinstance(logger, weakref.ref):
continue logger = logger()
logger = logger() # That's a weakref
if not hasattr(logger, 'stream'): if not hasattr(logger, 'stream'):
continue continue
if logger.stream is sys.stdout._real: if logger.stream is sys.stdout._real: