Skip to content

Commit 386b6f0

Browse files
tirkarthiZheaoli
authored andcommitted
[3.7] bpo-35726: Prevented QueueHandler formatting from affecting other handlers (GH-11537) (GH-12716)
QueueHandler.prepare() now makes a copy of the record before modifying and enqueueing it, to avoid affecting other handlers in the chain. (cherry picked from commit da6424e) Co-authored-by: Manjusaka <[email protected]>
1 parent 0ff08b0 commit 386b6f0

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

Lib/logging/handlers.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
from stat import ST_DEV, ST_INO, ST_MTIME
2828
import queue
2929
import threading
30+
import copy
3031

3132
#
3233
# Some constants...
@@ -1377,6 +1378,8 @@ def prepare(self, record):
13771378
# exc_info and exc_text attributes, as they are no longer
13781379
# needed and, if not None, will typically not be pickleable.
13791380
msg = self.format(record)
1381+
# bpo-35726: make copy of record to avoid affecting other handlers in the chain.
1382+
record = copy.copy(record)
13801383
record.message = msg
13811384
record.msg = msg
13821385
record.args = None
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
QueueHandler.prepare() now makes a copy of the record before modifying and enqueueing it, to avoid affecting other handlers in the chain.

0 commit comments

Comments
 (0)