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

Skip to content

Commit ba205d6

Browse files
committed
If cPickle isn't available, use pickle.
1 parent 06a2dc7 commit ba205d6

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

Lib/logging/handlers.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,11 @@
2727
To use, simply 'import logging' and log away!
2828
"""
2929

30-
import sys, logging, socket, types, os, string, cPickle, struct, time, glob
30+
import sys, logging, socket, types, os, string, struct, time, glob
31+
try:
32+
import cPickle as pickle
33+
except ImportError:
34+
import pickle
3135

3236
try:
3337
import codecs
@@ -389,7 +393,7 @@ def makePickle(self, record):
389393
if ei:
390394
dummy = self.format(record) # just to get traceback text into record.exc_text
391395
record.exc_info = None # to avoid Unpickleable error
392-
s = cPickle.dumps(record.__dict__, 1)
396+
s = pickle.dumps(record.__dict__, 1)
393397
if ei:
394398
record.exc_info = ei # for next handler
395399
slen = struct.pack(">L", len(s))

0 commit comments

Comments
 (0)