From: Vinay Sajip Date: Thu, 29 Mar 2012 19:17:18 +0000 (+0100) Subject: Closes #14436: Convert msg + args to string before pickling. X-Git-Tag: v3.3.0a2~27^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6f5e54e76915d9a8767f7241f0e835116877e6e5;p=thirdparty%2FPython%2Fcpython.git Closes #14436: Convert msg + args to string before pickling. --- diff --git a/Lib/logging/handlers.py b/Lib/logging/handlers.py index fed8c9393d61..7689b040c601 100644 --- a/Lib/logging/handlers.py +++ b/Lib/logging/handlers.py @@ -519,11 +519,16 @@ class SocketHandler(logging.Handler): """ ei = record.exc_info if ei: - dummy = self.format(record) # just to get traceback text into record.exc_text - record.exc_info = None # to avoid Unpickleable error - s = pickle.dumps(record.__dict__, 1) - if ei: - record.exc_info = ei # for next handler + # just to get traceback text into record.exc_text ... + dummy = self.format(record) + # See issue #14436: If msg or args are objects, they may not be + # available on the receiving end. So we convert the msg % args + # to a string, save it as msg and zap the args. + d = dict(record.__dict__) + d['msg'] = record.getMessage() + d['args'] = None + d['exc_info'] = None + s = pickle.dumps(d, 1) slen = struct.pack(">L", len(s)) return slen + s