GNOME Bugzilla – Bug 723074
Fatal error downloading subtitle
Last modified: 2014-01-30 10:52:15 UTC
Those are the changes I have right now for more Python3 porting: diff --git a/src/plugins/opensubtitles/opensubtitles.py b/src/plugins/opensubtitles/opensubtitles.py index dcf71f1..ad2d906 100644 --- a/src/plugins/opensubtitles/opensubtitles.py +++ b/src/plugins/opensubtitles/opensubtitles.py @@ -6,6 +6,8 @@ from gi.repository import Gio, Pango, Totem # pylint: disable-msg=E0611 import xmlrpc.client import threading +from io import StringIO +import gzip, base64 from os import sep, path, mkdir import gettext @@ -354,9 +356,8 @@ class OpenSubtitlesModel (object): self._lock.release () return (None, error_message) - import StringIO, gzip, base64 - subtitle_decoded = base64.decodestring (subtitle64) - subtitle_gzipped = StringIO.StringIO (subtitle_decoded) + subtitle_decoded = base64.decodestring (bytes(subtitle64, 'utf-8')) + subtitle_gzipped = StringIO (str(subtitle_decoded)) subtitle_gzipped_file = gzip.GzipFile (fileobj=subtitle_gzipped) self._lock.release () Unfortunately it still fails with: Exception in thread Thread-2: Traceback (most recent call last):
+ Trace 233086
self.run()
self._message) = self._model.download_subtitles (self._subtitle_id)
return (subtitle_gzipped_file.read (), message)
self._read(readsize)
self._read_gzip_header()
magic = self.fileobj.read(2)
self.file.read(size-self._length+read)
Looks like a bug in Python itself? We should probably look at using Gio.ZlibDecompressor instead.
I couldn't figure out how to GConverter from Python, even with those docs: http://lazka.github.io/pgi-docs/api/Gio_2.0/interfaces/Converter.html#Gio.Converter It expected an allocated buffer as the "out" parameter, when GConverter is the one allocating it... commit 9d6a14fc25515772048ef07a2dc7343241277a43 Author: Bastien Nocera <hadess@hadess.net> Date: Thu Jan 30 11:48:56 2014 +0100 opensubtitles: Make decoding download items work Stop using StringIO, gzip and base64 modules, and use GLib for the base64 decoding, and zlib for the decompression. https://bugzilla.gnome.org/show_bug.cgi?id=723074