From 39b12bbf7ff01c6cb335257071b851970c3e8239 Mon Sep 17 00:00:00 2001 From: Bas Hulsken Date: Mon, 6 Jan 2020 11:21:39 +1100 Subject: [PATCH] Fix sugar-install-bundle - Python 2 On Python 2 is seen ConfigParser instance has no attribute 'read_string' Regression introduced by 2018c930adae85c18b1c51b5f80836fcad6c392c Fixes https://github.com/sugarlabs/sugar-toolkit-gtk3/issues/438 Signed-off-by: James Cameron --- src/sugar3/bundle/activitybundle.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/sugar3/bundle/activitybundle.py b/src/sugar3/bundle/activitybundle.py index ec1b47ca..87aa79c7 100644 --- a/src/sugar3/bundle/activitybundle.py +++ b/src/sugar3/bundle/activitybundle.py @@ -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