__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
-import cPickle
+import SCons.compat
+
import dis
import os
+# compat layer imports "cPickle" for us if it's available.
+import pickle
import re
import sys
import subprocess
except AttributeError:
# Should be a pickable Python object.
try:
- return cPickle.dumps(obj)
- except (cPickle.PicklingError, TypeError):
+ return pickle.dumps(obj)
+ except (pickle.PicklingError, TypeError):
# This is weird, but it seems that nested classes
# are unpickable. The Python docs say it should
# always be a PicklingError, but some Python
__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
-import cPickle
+import SCons.compat
+
import os
-import os.path
+# compat layer imports "cPickle" for us if it's available.
+import pickle
import SCons.dblite
import SCons.Warnings
pass
else:
try:
- self.entries = cPickle.loads(rawentries)
+ self.entries = pickle.loads(rawentries)
if not isinstance(self.entries, dict):
self.entries = {}
raise TypeError
path = normcase(self.dir.path)
for key, entry in self.entries.items():
entry.convert_to_sconsign()
- db[path] = cPickle.dumps(self.entries, 1)
+ db[path] = pickle.dumps(self.entries, 1)
if sync:
try:
if not fp:
return
- self.entries = cPickle.load(fp)
+ self.entries = pickle.load(fp)
if not isinstance(self.entries, dict):
self.entries = {}
raise TypeError
return
for key, entry in self.entries.items():
entry.convert_to_sconsign()
- cPickle.dump(self.entries, file, 1)
+ pickle.dump(self.entries, file, 1)
file.close()
if fname != self.sconsign:
try:
__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+import SCons.compat
+
import base64
-import cPickle
import hashlib
import ntpath
import os
+# compat layer imports "cPickle" for us if it's available.
+import pickle
import re
import sys
if self.nokeep == 0:
# now we pickle some data and add it to the file -- MSDEV will ignore it.
- pdata = cPickle.dumps(self.configs,1)
+ pdata = pickle.dumps(self.configs,1)
pdata = base64.encodestring(pdata)
self.file.write(pdata + '\n')
- pdata = cPickle.dumps(self.sources,1)
+ pdata = pickle.dumps(self.sources,1)
pdata = base64.encodestring(pdata)
self.file.write(pdata + '\n')
# OK, we've found our little pickled cache of data.
try:
datas = base64.decodestring(datas)
- data = cPickle.loads(datas)
+ data = pickle.loads(datas)
except KeyboardInterrupt:
raise
except:
# it has a "# " in front of it, so we strip that.
try:
datas = base64.decodestring(datas)
- data = cPickle.loads(datas)
+ data = pickle.loads(datas)
except KeyboardInterrupt:
raise
except:
if self.nokeep == 0:
# now we pickle some data and add it to the file -- MSDEV will ignore it.
- pdata = cPickle.dumps(self.configs,1)
+ pdata = pickle.dumps(self.configs,1)
pdata = base64.encodestring(pdata)
self.file.write('<!-- SCons Data:\n' + pdata + '\n')
- pdata = cPickle.dumps(self.sources,1)
+ pdata = pickle.dumps(self.sources,1)
pdata = base64.encodestring(pdata)
self.file.write(pdata + '-->\n')
# OK, we've found our little pickled cache of data.
try:
datas = base64.decodestring(datas)
- data = cPickle.loads(datas)
+ data = pickle.loads(datas)
except KeyboardInterrupt:
raise
except:
# OK, we've found our little pickled cache of data.
try:
datas = base64.decodestring(datas)
- data = cPickle.loads(datas)
+ data = pickle.loads(datas)
except KeyboardInterrupt:
raise
except:
# OK, we've found our little pickled cache of data.
try:
datas = base64.decodestring(datas)
- data = cPickle.loads(datas)
+ data = pickle.loads(datas)
except KeyboardInterrupt:
raise
except:
'\tEndGlobalSection\n')
self.file.write('EndGlobal\n')
if self.nokeep == 0:
- pdata = cPickle.dumps(self.configs,1)
+ pdata = pickle.dumps(self.configs,1)
pdata = base64.encodestring(pdata)
self.file.write(pdata + '\n')
os.path.lexists = lexists
+try:
+ # Use the "imp" module to protect the import from fixers.
+ import imp
+ cPickle = imp.load_module('cPickle', *imp.find_module('cPickle'))
+except ImportError, e:
+ # The "cPickle" module has already been eliminated in favor of
+ # having "import pickle" import the fast version when available.
+ pass
+else:
+ import sys
+ sys.modules['pickle'] = cPickle
+ del cPickle
+
+
try:
# Use the "imp" module to protect the import from fixers.
import imp
# dblite.py module contributed by Ralf W. Grosse-Kunstleve.
# Extended for Unicode by Steven Knight.
-import cPickle
-import time
-import shutil
+import SCons.compat
+
import os
+# compat layer imports "cPickle" for us if it's available.
+import pickle
+import shutil
+import time
import __builtin__
keep_all_files = 00000
# http://mail.python.org/pipermail/python-bugs-list/2003-March/016877.html
_open = __builtin__.open
- _cPickle_dump = cPickle.dump
+ _pickle_dump = pickle.dump
_os_chmod = os.chmod
try:
_os_chown = os.chown
p = f.read()
if (len(p) > 0):
try:
- self._dict = cPickle.loads(p)
- except (cPickle.UnpicklingError, EOFError):
+ self._dict = pickle.loads(p)
+ except (pickle.UnpicklingError, EOFError):
if (ignore_corrupt_dbfiles == 0): raise
if (ignore_corrupt_dbfiles == 1):
corruption_warning(self._file_name)
def sync(self):
self._check_writable()
f = self._open(self._tmp_name, "wb", self._mode)
- self._cPickle_dump(self._dict, f, 1)
+ self._pickle_dump(self._dict, f, 1)
f.close()
# Windows doesn't allow renaming if the file exists, so unlink
# it first, chmod'ing it to make sure we can do so. On UNIX, we
assert len(db) == 5
db = open("tmp", "n")
assert len(db) == 0
- _open("tmp.dblite", "w")
+ dblite._open("tmp.dblite", "w")
db = open("tmp", "r")
- _open("tmp.dblite", "w").write("x")
+ dblite._open("tmp.dblite", "w").write("x")
try:
db = open("tmp", "r")
- except cPickle.UnpicklingError:
+ except pickle.UnpicklingError:
pass
else:
- raise RuntimeError, "cPickle exception expected."
+ raise RuntimeError, "pickle exception expected."
global ignore_corrupt_dbfiles
ignore_corrupt_dbfiles = 2
db = open("tmp", "r")