From f16afc59ba84d6535ed90d90119cc4e7012a504d Mon Sep 17 00:00:00 2001 From: Calum Lind Date: Sun, 25 Jul 2021 11:16:03 +0100 Subject: Ignore TypeError with custom Twisted logging The modification of Python logging _findCaller args in Python 3.8 raises TypeError in our custom Twisted Logger with Twisted <= 19 versions. The actual issue for the custom logger was fixed in 18.9 so added a version check to avoid usage. Refs: - https://twistedmatrix.com/trac/ticket/7927 - https://github.com/twisted/twisted/commit/6b894744e4d2439c1a4436d1e0e0b2a6cdff68e4 --- deluge/log.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/deluge/log.py b/deluge/log.py index bf4f3c2d7..fa83091d1 100644 --- a/deluge/log.py +++ b/deluge/log.py @@ -17,6 +17,8 @@ import logging.handlers import os import sys +from incremental import Version +from twisted import version as twisted_version from twisted.internet import defer from twisted.python.log import PythonLoggingObserver @@ -180,7 +182,8 @@ def setup_logger( root_logger.addHandler(handler) root_logger.setLevel(level) - if twisted_observer: + # Issue fixed in Twisted 18.9.0 https://twistedmatrix.com/trac/ticket/7927 + if twisted_observer and twisted_version < Version('Twisted', 18, 9, 0): twisted_logging = TwistedLoggingObserver() twisted_logging.start() @@ -204,8 +207,13 @@ class TwistedLoggingObserver(PythonLoggingObserver): getattr(LoggingLoggerClass, event_dict['log_level'].name)( log, fmt % (event_dict) ) - else: + return + + try: PythonLoggingObserver.emit(self, event_dict) + except TypeError: + # Ignore logging args problem with Python 3.8 and Twisted <= 19 + pass def tweak_logging_levels(): -- cgit