]> granicus.if.org Git - python/commitdiff
bpo-35726: Prevented QueueHandler formatting from affecting other handlers (GH-11537)
authorManjusaka <lizheao940510@gmail.com>
Wed, 23 Jan 2019 07:08:38 +0000 (15:08 +0800)
committerVinay Sajip <vinay_sajip@yahoo.co.uk>
Wed, 23 Jan 2019 07:08:38 +0000 (07:08 +0000)
QueueHandler.prepare() now makes a copy of the record before modifying and enqueueing it, to avoid affecting other handlers in the chain.

Lib/logging/handlers.py
Misc/NEWS.d/next/Library/2019-01-13-01-33-00.bpo-35726.dasdas.rst [new file with mode: 0644]

index e213e438c31aa140f696fb69f4ee249762d521b1..3727bf0677cdcef7afcb9c0e448a5e083e07ec77 100644 (file)
@@ -27,6 +27,7 @@ import logging, socket, os, pickle, struct, time, re
 from stat import ST_DEV, ST_INO, ST_MTIME
 import queue
 import threading
+import copy
 
 #
 # Some constants...
@@ -1377,6 +1378,8 @@ class QueueHandler(logging.Handler):
         # exc_info and exc_text attributes, as they are no longer
         # needed and, if not None, will typically not be pickleable.
         msg = self.format(record)
+        # bpo-35726: make copy of record to avoid affecting other handlers in the chain.
+        record = copy.copy(record)
         record.message = msg
         record.msg = msg
         record.args = None
diff --git a/Misc/NEWS.d/next/Library/2019-01-13-01-33-00.bpo-35726.dasdas.rst b/Misc/NEWS.d/next/Library/2019-01-13-01-33-00.bpo-35726.dasdas.rst
new file mode 100644 (file)
index 0000000..f47cdc1
--- /dev/null
@@ -0,0 +1 @@
+QueueHandler.prepare() now makes a copy of the record before modifying and enqueueing it, to avoid affecting other handlers in the chain.