[Python-3000-checkins] r51338 - python/branches/p3yk/Lib/logging/handlers.py

guido.van.rossum python-3000-checkins at python.org
Thu Aug 17 10:57:27 CEST 2006


Author: guido.van.rossum
Date: Thu Aug 17 10:57:26 2006
New Revision: 51338

Modified:
   python/branches/p3yk/Lib/logging/handlers.py
Log:
If cPickle isn't available, use pickle.


Modified: python/branches/p3yk/Lib/logging/handlers.py
==============================================================================
--- python/branches/p3yk/Lib/logging/handlers.py	(original)
+++ python/branches/p3yk/Lib/logging/handlers.py	Thu Aug 17 10:57:26 2006
@@ -27,7 +27,11 @@
 To use, simply 'import logging' and log away!
 """
 
-import sys, logging, socket, types, os, string, cPickle, struct, time, glob
+import sys, logging, socket, types, os, string, struct, time, glob
+try:
+    import cPickle as pickle
+except ImportError:
+    import pickle
 
 try:
     import codecs
@@ -389,7 +393,7 @@
         if ei:
             dummy = self.format(record) # just to get traceback text into record.exc_text
             record.exc_info = None  # to avoid Unpickleable error
-        s = cPickle.dumps(record.__dict__, 1)
+        s = pickle.dumps(record.__dict__, 1)
         if ei:
             record.exc_info = ei  # for next handler
         slen = struct.pack(">L", len(s))


More information about the Python-3000-checkins mailing list