简体   繁体   中英

python typeerror unbound method emit must be called with streamhandler instance as fistr argument (got filehandler instance instead)

python module paramiko throw a strange exception as shown on the tile. And finally I find the position it really occurs which is in the module logging . when I set a breakpoint on the line in Eclipse with pydev, and put lines below in the expressions view, the evaluated value confused me. I wonder that in what circumstance the exception may happen, though it's impossible from my view.

self.__class__ # <class 'logging.FileHandler'>
isinstance(self, FileHandler)  # False
isinstance(self, StreamHandler) # False

emit method of FileHandler:

def emit(self, record):
    """
    Emit a record.

    If the stream was not opened because 'delay' was specified in the
    constructor, open it before calling the superclass's emit.
    """
    if self.stream is None:
        self.stream = self._open()
    StreamHandler.emit(self, record)

Finally fixed it. Reloading the module logging caused this issue.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM