Vinay Sajip <vinay_sa...@yahoo.co.uk> added the comment:
This doesn't appear to be inherently a logging problem - it seems to be a change in how copy.copy() is working. If you update mocked_log to insert some statements showing the id of the loggers involved in the copy: def mocked_log(log_level): # Return a copy as the bot may modify the logger and we should always return the intial logger print('copying %x' % id(logger)) assert logger.handlers logger_new = copy.copy(logger) logger_new.setLevel(log_level) print('copied to %x' % id(logger_new)) return logger_new Then under Python3.6 you get something like copying 7f2682b3a780 copied to 7f268145bc50 copying 7f2682b3a780 copied to 7f268145bcf8 INFO - Initialized DEBUG - test INFO - Bot stopped. Note the different ids of the copy source and target, and that the assertion failure isn't triggered. Under 3.7, you get copying 7f7084171b38 copied to 7f7084171b38 copying 7f7084171b38 Traceback (most recent call last): File "test.py", line 31, in <module> bot = Bot() File "/home/vinay/projects/scratch/python/34999/bot.py", line 12, in __init__ self.__init_logger(logging_level='DEBUG') File "/home/vinay/projects/scratch/python/34999/bot.py", line 17, in __init_logger self.logger = log(log_level=logging_level) File "test.py", line 23, in mocked_log assert logger.handlers AssertionError So - copy.copy() hasn't actually made a copy of the logger, it's returned the original. I'm not sure why this is. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue34999> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com