diff options
author | William Deegan <bill@baddogconsulting.com> | 2017-09-10 20:54:12 -0700 |
---|---|---|
committer | William Deegan <bill@baddogconsulting.com> | 2017-09-10 20:54:12 -0700 |
commit | eb6c13f040ac9ae7d01c72402fdc666491979bd6 (patch) | |
tree | c67c23f2dc5398d4e643bb95de1b61b4007b72ad | |
parent | 44edd31d2042bd4f3efe4975ec6446b821746bdb (diff) | |
download | scons-eb6c13f040ac9ae7d01c72402fdc666491979bd6.tar.gz |
PY2/3 changes to pickle so py2.7 and py3.5+ pickles used in sconsign will be readable by either. There are still rebuilds when switching
-rw-r--r-- | src/engine/SCons/compat/__init__.py | 4 | ||||
-rw-r--r-- | src/engine/SCons/dblite.py | 5 |
2 files changed, 7 insertions, 2 deletions
diff --git a/src/engine/SCons/compat/__init__.py b/src/engine/SCons/compat/__init__.py index 59a1a94d..0b6c016a 100644 --- a/src/engine/SCons/compat/__init__.py +++ b/src/engine/SCons/compat/__init__.py @@ -96,7 +96,9 @@ rename_module('pickle', 'cPickle') # Negative numbers choose the highest available protocol. import pickle -PICKLE_PROTOCOL = pickle.HIGHEST_PROTOCOL +# Was pickle.HIGHEST_PROTOCOL +# Changed to 2 so py3.5+'s pickle will be compatible with py2.7. +PICKLE_PROTOCOL = 2 # TODO: FIXME # In 3.x, 'profile' automatically loads the fast version if available. diff --git a/src/engine/SCons/dblite.py b/src/engine/SCons/dblite.py index a9b9589a..87a17631 100644 --- a/src/engine/SCons/dblite.py +++ b/src/engine/SCons/dblite.py @@ -119,7 +119,10 @@ class dblite(object): p = f.read() if len(p) > 0: try: - self._dict = pickle.loads(p) + if bytes is not str: + self._dict = pickle.loads(p, encoding='bytes') + else: + self._dict = pickle.loads(p) except (pickle.UnpicklingError, EOFError, KeyError): # Note how we catch KeyErrors too here, which might happen # when we don't have cPickle available (default pickle |