diff options
| author | Vinay Sajip <vinay_sajip@yahoo.co.uk> | 2012-03-29 19:11:20 (GMT) |
|---|---|---|
| committer | Vinay Sajip <vinay_sajip@yahoo.co.uk> | 2012-03-29 19:11:20 (GMT) |
| commit | 7ce9bda575313b66ca0a5cbcf6d6d30f9546a894 (patch) | |
| tree | fd991837562d3f3e240217d2de812d140780c0ea | |
| parent | c37db10e03d863ee143d22244c0a405c8a004280 (diff) | |
| download | cpython-7ce9bda575313b66ca0a5cbcf6d6d30f9546a894.zip cpython-7ce9bda575313b66ca0a5cbcf6d6d30f9546a894.tar.gz cpython-7ce9bda575313b66ca0a5cbcf6d6d30f9546a894.tar.bz2 | |
Closes #14436: Convert msg + args to string before pickling.
| -rw-r--r-- | Lib/logging/handlers.py | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/Lib/logging/handlers.py b/Lib/logging/handlers.py index 3ff324d..6bbc1f7 100644 --- a/Lib/logging/handlers.py +++ b/Lib/logging/handlers.py @@ -528,9 +528,16 @@ class SocketHandler(logging.Handler): """ ei = record.exc_info if ei: - dummy = self.format(record) # just to get traceback text into record.exc_text + # just to get traceback text into record.exc_text ... + dummy = self.format(record) record.exc_info = None # to avoid Unpickleable error - s = cPickle.dumps(record.__dict__, 1) + # 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 + s = cPickle.dumps(d, 1) if ei: record.exc_info = ei # for next handler slen = struct.pack(">L", len(s)) |
