Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6f5e54e

Browse files
committed
Closes #14436: Convert msg + args to string before pickling.
1 parent 67ac079 commit 6f5e54e

1 file changed

Lines changed: 10 additions & 5 deletions

File tree

Lib/logging/handlers.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -519,11 +519,16 @@ def makePickle(self, record):
519519
"""
520520
ei = record.exc_info
521521
if ei:
522-
dummy = self.format(record) # just to get traceback text into record.exc_text
523-
record.exc_info = None # to avoid Unpickleable error
524-
s = pickle.dumps(record.__dict__, 1)
525-
if ei:
526-
record.exc_info = ei # for next handler
522+
# just to get traceback text into record.exc_text ...
523+
dummy = self.format(record)
524+
# See issue #14436: If msg or args are objects, they may not be
525+
# available on the receiving end. So we convert the msg % args
526+
# to a string, save it as msg and zap the args.
527+
d = dict(record.__dict__)
528+
d['msg'] = record.getMessage()
529+
d['args'] = None
530+
d['exc_info'] = None
531+
s = pickle.dumps(d, 1)
527532
slen = struct.pack(">L", len(s))
528533
return slen + s
529534

0 commit comments

Comments
 (0)