From be02be75be9068eed354e6d840b5fc234ff373a7 Mon Sep 17 00:00:00 2001 From: Calum Lind Date: Sun, 1 Jul 2018 20:34:42 +0100 Subject: [PATCH] [GTKUI|Py3] Ensure backward compatible pickle dumps --- deluge/core/torrentmanager.py | 2 +- deluge/ui/gtkui/common.py | 2 +- deluge/ui/gtkui/files_tab.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/deluge/core/torrentmanager.py b/deluge/core/torrentmanager.py index 38cdcbf49..62e1d2508 100644 --- a/deluge/core/torrentmanager.py +++ b/deluge/core/torrentmanager.py @@ -861,7 +861,7 @@ class TorrentManager(component.Component): try: log.debug('Creating the temporary file: %s', filepath_tmp) with open(filepath_tmp, 'wb', 0) as _file: - pickle.dump(state, _file) + pickle.dump(state, _file, protocol=2) _file.flush() os.fsync(_file.fileno()) except (OSError, pickle.PicklingError) as ex: diff --git a/deluge/ui/gtkui/common.py b/deluge/ui/gtkui/common.py index c6622f1e0..a8701b49a 100644 --- a/deluge/ui/gtkui/common.py +++ b/deluge/ui/gtkui/common.py @@ -264,7 +264,7 @@ def save_pickled_state_file(filename, state): try: with open(filepath_tmp, 'wb') as _file: # Pickle the state object - pickle.dump(state, _file) + pickle.dump(state, _file, protocol=2) _file.flush() os.fsync(_file.fileno()) shutil.move(filepath_tmp, filepath) diff --git a/deluge/ui/gtkui/files_tab.py b/deluge/ui/gtkui/files_tab.py index 94ee359a4..79cb66188 100644 --- a/deluge/ui/gtkui/files_tab.py +++ b/deluge/ui/gtkui/files_tab.py @@ -757,7 +757,7 @@ class FilesTab(Tab): def _on_drag_data_get_data(self, treeview, context, selection, target_id, etime): paths = self.listview.get_selection().get_selected_rows()[1] - selection.set_text(pickle.dumps(paths)) + selection.set_text(pickle.dumps(paths, protocol=2)) def _on_drag_data_received_data(self, treeview, context, x, y, selection, info, etime): try: