diff --git a/src/calibre/ptempfile.py b/src/calibre/ptempfile.py index ca758fe954..56ce1c5b4f 100644 --- a/src/calibre/ptempfile.py +++ b/src/calibre/ptempfile.py @@ -105,10 +105,11 @@ def base_dir(): if _base_dir is None: td = os.environ.get('CALIBRE_WORKER_TEMP_DIR', None) if td is not None: - import cPickle, binascii + import binascii + from calibre.utils.serialize import msgpack_loads try: - td = cPickle.loads(binascii.unhexlify(td)) - except: + td = msgpack_loads(binascii.unhexlify(td)) + except Exception: td = None if td and os.path.exists(td): _base_dir = td diff --git a/src/calibre/utils/ipc/launch.py b/src/calibre/utils/ipc/launch.py index b0c777518d..14e80d9eb1 100644 --- a/src/calibre/utils/ipc/launch.py +++ b/src/calibre/utils/ipc/launch.py @@ -6,12 +6,13 @@ __license__ = 'GPL v3' __copyright__ = '2009, Kovid Goyal ' __docformat__ = 'restructuredtext en' -import subprocess, os, sys, time, binascii, cPickle +import subprocess, os, sys, time, binascii from functools import partial from calibre.constants import iswindows, isosx, isfrozen, filesystem_encoding from calibre.utils.config import prefs from calibre.ptempfile import PersistentTemporaryFile, base_dir +from calibre.utils.serialize import msgpack_dumps from polyglot.builtins import unicode_type, string_or_bytes if iswindows: @@ -104,9 +105,9 @@ class Worker(object): env[key] = val except: pass - env[b'CALIBRE_WORKER'] = b'1' - td = binascii.hexlify(cPickle.dumps(base_dir())) - env[b'CALIBRE_WORKER_TEMP_DIR'] = bytes(td) + env[str('CALIBRE_WORKER')] = str('1') + td = binascii.hexlify(msgpack_dumps(base_dir())).decode('ascii') + env[b'CALIBRE_WORKER_TEMP_DIR'] = str(td) env.update(self._env) return env @@ -176,13 +177,11 @@ class Worker(object): exe = self.gui_executable if self.gui else self.executable env = self.env try: - env[b'ORIGWD'] = binascii.hexlify(cPickle.dumps( - cwd or os.path.abspath(os.getcwdu()))) + origwd = cwd or os.path.abspath(os.getcwdu()) except EnvironmentError: # cwd no longer exists - env[b'ORIGWD'] = binascii.hexlify(cPickle.dumps( - cwd or os.path.expanduser(u'~'))) - + origwd = cwd or os.path.expanduser(u'~') + env[str('ORIGWD')] = binascii.hexlify(msgpack_dumps(origwd)) _cwd = cwd if priority is None: priority = prefs['worker_process_priority']