diff --git a/deluge/ui/gtkui/addtorrentdialog.py b/deluge/ui/gtkui/addtorrentdialog.py index fdaa896b9..76cd7c695 100644 --- a/deluge/ui/gtkui/addtorrentdialog.py +++ b/deluge/ui/gtkui/addtorrentdialog.py @@ -683,7 +683,7 @@ class AddTorrentDialog(component.Component): for i, f in enumerate(torrent_filenames): client.core.add_torrent_file( os.path.split(f)[-1], - base64.encodestring(open(f).read()), + base64.encodestring(open(f, "rb").read()), torrent_options[i]) if torrent_magnets: client.core.add_torrent_magnets(torrent_magnets, torrent_magnet_options) diff --git a/deluge/ui/web/json_api.py b/deluge/ui/web/json_api.py index 6475e8773..73318894d 100644 --- a/deluge/ui/web/json_api.py +++ b/deluge/ui/web/json_api.py @@ -420,7 +420,7 @@ class WebApi(JSONComponent): """ for torrent in torrents: filename = os.path.basename(torrent["path"]) - fdump = base64.encodestring(open(torrent["path"], "r").read()) + fdump = base64.encodestring(open(torrent["path"], "rb").read()) log.info("Adding torrent from file `%s` with options `%r`", filename, torrent["options"]) client.core.add_torrent_file(filename, fdump, torrent["options"])