From 58224cb15d84765e79492c7bb513e952e856cbfe Mon Sep 17 00:00:00 2001 From: James Cameron Date: Thu, 24 May 2018 11:11:50 +1000 Subject: [PATCH] Fix traceback when an icon name matches a GNOME theme icon When an icon file name matches a GNOME theme icon; Traceback (most recent call last): File "/usr/lib/python2.7/dist-packages/sugar3/graphics/icon.py", line 214, in _get_attach_points cp.readfp(config_file) File "/usr/lib/python2.7/ConfigParser.py", line 324, in readfp self._read(fp, filename) File "/usr/lib/python2.7/ConfigParser.py", line 512, in _read raise MissingSectionHeaderError(fpname, lineno, line) MissingSectionHeaderError: File contains no section headers. Caused by reading a .png file as if it were config file, in turn because the icon was expected by the toolkit to be .svg file type. Regression introduced by f796638. Fixes https://github.com/sugarlabs/activity-abacus/issues/16 --- src/sugar3/graphics/icon.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/sugar3/graphics/icon.py b/src/sugar3/graphics/icon.py index 06883728..f0bfc806 100644 --- a/src/sugar3/graphics/icon.py +++ b/src/sugar3/graphics/icon.py @@ -205,7 +205,9 @@ class _IconBuffer(object): elif info.get_filename(): # try read from the .icon file icon_filename = info.get_filename().replace('.svg', '.icon') - if os.path.exists(icon_filename): + if icon_filename != info.get_filename() and \ + os.path.exists(icon_filename): + try: with open(icon_filename) as config_file: cp = ConfigParser()