Closed bhulsken closed 4 years ago
Thanks. What version of Python? Did you also test installing activity bundles from Browse or Terminal? The change to read_string was made so installing would work, and was tested on Python 3.8. read_string is documented as supported. If you are using Python 2, we will have to wrap this code in a version test.
my mistake, forgot to test for python3, indeed this change is needed for python2, but breaks the python3 version (just checked).
according to internet wisdom (see e.g. here https://stackoverflow.com/questions/34447623/wrap-an-open-stream-with-io-textiowrapper) there is no code that would work with python2 and python3, so a version check is needed indeed. Below patch works for me, now actually tested with both python2 and python3 :$
best regards, Bas Hulsken
diff -Naupr sugar-toolkit-gtk3/src/sugar3/bundle/activitybundle.py sugar-toolkit-gtk3-fix/src/sugar3/bundle/activitybundle.py
--- sugar-toolkit-gtk3/src/sugar3/bundle/activitybundle.py 2019-12-31 11:15:36.182323699 +0100
+++ sugar-toolkit-gtk3-fix/src/sugar3/bundle/activitybundle.py 2020-01-02 19:52:02.703951092 +0100
@@ -21,6 +21,7 @@ UNSTABLE.
"""
from six.moves.configparser import ConfigParser, ParsingError
+import six
from locale import normalize
import os
import shutil
@@ -129,7 +130,10 @@ class ActivityBundle(Bundle):
def _parse_info(self, info_file):
cp = ConfigParser()
- cp.read_string(info_file.read().decode())
+ if six.PY2:
+ cp.readfp(info_file)
+ else:
+ cp.read_string(info_file.read().decode())
section = 'Activity'
@@ -251,7 +255,10 @@ class ActivityBundle(Bundle):
def _parse_linfo(self, linfo_file):
cp = ConfigParser()
try:
- cp.read_string(linfo_file.read().decode())
+ if six.PY2:
+ cp.readfp(linfo_file)
+ else:
+ cp.read_string(linfo_file.read().decode())
except ParsingError as e:
logging.exception('Exception reading linfo file: %s', e)
return
read_string not supported, as far as I can see, readfp should work in this case. Seems to work for me at least. Below patch works for me so far.