Hmm, I have solved the same error in Read yesterday.<div>I should tell you.</div><div>Or may be we should add code in icon to convert to str if the parameter is unicode?</div><div><br></div><div>Gonzalo </div><div><br><div class="gmail_quote">
On Thu, Mar 29, 2012 at 11:50 AM, Manuel Quiñones <span dir="ltr"><<a href="mailto:manuq@laptop.org">manuq@laptop.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Color parameter in get_image() method of class LinkButton is being<br>
passed with type str when inside a session, but is type unicode when<br>
read from a previous session, because json stores unicode. And<br>
Rsvg.Handle.new_from_data() needs a single byte string.<br>
<br>
This fixes #3402 .<br>
<br>
Also removed unused parameters in LinkButton constructor.<br>
<br>
Signed-off-by: Manuel Quiñones <<a href="mailto:manuq@laptop.org">manuq@laptop.org</a>><br>
---<br>
linkbutton.py | 7 ++++++-<br>
webactivity.py | 2 +-<br>
2 files changed, 7 insertions(+), 2 deletions(-)<br>
<br>
diff --git a/linkbutton.py b/linkbutton.py<br>
index 2804397..d1b4ea9 100644<br>
--- a/linkbutton.py<br>
+++ b/linkbutton.py<br>
@@ -40,8 +40,13 @@ class LinkButton(TrayButton, GObject.GObject):<br>
None, ([str])),<br>
}<br>
<br>
- def __init__(self, url, buf, color, title, owner, index, hash):<br>
+ def __init__(self, buf, color, title, owner, hash):<br>
TrayButton.__init__(self)<br>
+<br>
+ # Color read from the Journal may be Unicode, but Rsvg needs<br>
+ # it as single byte string:<br>
+ if isinstance(color, unicode):<br>
+ color = str(color)<br>
self.set_image(buf, color.split(',')[1], color.split(',')[0])<br>
<br>
self.hash = hash<br>
diff --git a/webactivity.py b/webactivity.py<br>
index e156173..aadc29a 100644<br>
--- a/webactivity.py<br>
+++ b/webactivity.py<br>
@@ -518,7 +518,7 @@ class WebActivity(activity.Activity):<br>
<br>
def _add_link_totray(self, url, buf, color, title, owner, index, hash):<br>
''' add a link to the tray '''<br>
- item = LinkButton(url, buf, color, title, owner, index, hash)<br>
+ item = LinkButton(buf, color, title, owner, hash)<br>
item.connect('clicked', self._link_clicked_cb, url)<br>
item.connect('remove_link', self._link_removed_cb)<br>
# use index to add to the tray<br>
<span class="HOEnZb"><font color="#888888">--<br>
1.7.7.6<br>
<br>
_______________________________________________<br>
Sugar-devel mailing list<br>
<a href="mailto:Sugar-devel@lists.sugarlabs.org">Sugar-devel@lists.sugarlabs.org</a><br>
<a href="http://lists.sugarlabs.org/listinfo/sugar-devel" target="_blank">http://lists.sugarlabs.org/listinfo/sugar-devel</a><br>
</font></span></blockquote></div><br></div>