Skip to content

Commit 467e6f0

Browse files
committed
QueueHandler.prepare() now makes a copy of the record before modifying and enqueueing it, to avoid affecting other handlers in the chain.
1 parent 1cffd0e commit 467e6f0

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-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: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
QueueHandler.prepare() now makes a copy of the record before modifying and enqueueing it, to avoid affecting other handlers in the chain.
2+

0 commit comments

Comments
 (0)