#1957 closed bug (Fixed)
Columns don't add resulting in keyerror for non-latin languages
Reported by: | Cas | Owned by: | Cas |
---|---|---|---|
Priority: | major | Milestone: | 2.x |
Component: | GTK UI | Version: | 1.3.3 |
Keywords: | Cc: | gymka2 |
Description
deluge-gtk crashed with KeyError in on_menuitem_toggled(): '\xd0\x97\xd0\xb0\xd0\xb3\xd1\x80\xd1\x83\xd0\xb6\xd0\xb5\xd0\xbd\xd0\xbe' Traceback: Traceback (most recent call last): File "/usr/lib/python2.7/dist-packages/deluge/ui/gtkui/listview.py", line 339, in on_menuitem_toggled self.columns[name].column.set_visible(widget.get_active()) KeyError: '\xd0\x97\xd0\xb0\xd0\xb3\xd1\x80\xd1\x83\xd0\xb6\xd0\xb5\xd0\xbd\xd0\xbe'
From: https://bugs.launchpad.net/ubuntu/+source/deluge/+bug/854648
A workaround patch from Serge Matveenko has been attached.
Attachments (1)
Change History (10)
Changed 12 years ago by Cas
comment:1 Changed 11 years ago by Cas
- Milestone changed from 1.3.4 to 1.4.0
- Owner set to Cas
- Status changed from new to accepted
comment:2 Changed 11 years ago by gymka2
this patch is bad! with it i can't hide/unhide columns if they has not latin letters, then i removed that patch everything is working. version 1.3.4
comment:3 Changed 11 years ago by gymka2
- Cc gymka2 added
comment:4 Changed 11 years ago by gymka2
btw without that patch nothing bad is hapening, everything works, program not crashes... only in console it gives that error
comment:5 follow-up: ↓ 6 Changed 11 years ago by Cas
Could you try the following patch and whether you still see console errors.
diff --git a/deluge/ui/gtkui/listview.py b/deluge/ui/gtkui/listview.py index 887f2cb..72613b3 100644 --- a/deluge/ui/gtkui/listview.py +++ b/deluge/ui/gtkui/listview.py @@ -333,10 +333,13 @@ def get_state_field_column(self, field): def on_menuitem_toggled(self, widget): """Callback for the generated column menuitems.""" # Get the column name from the widget - name = unicode(widget.get_child().get_text()) + name = widget.get_child().get_text() # Set the column's visibility based on the widgets active state - self.columns[name].column.set_visible(widget.get_active()) + try: + self.columns[name].column.set_visible(widget.get_active()) + except KeyError: + self.columns[unicode(name)].column.set_visible(widget.get_active()) return def on_treeview_header_right_clicked(self, column, event):
comment:6 in reply to: ↑ 5 Changed 11 years ago by gymka2
Replying to Cas:
Could you try the following patch and whether you still see console errors.
with this pacth everything works and there is no any errors.
comment:7 Changed 11 years ago by gymka2
tested with Lithuanian and Russian languages
comment:8 Changed 10 years ago by Cas
- Resolution set to fixed
- Status changed from accepted to closed
I am closing this issue because the problem is actually to do with menuitem get_text returning utf8 byte string not unicode string as stored in self.columns. It's also difficult to justify the amount of work required to add an 'id' entry when there are currently no more issues with translated columns.
I am still not sure about the issue seen by gymka2. I can't replicate it but it could be that the unicode decode requires 'utf8' specified but since the last fix works I am leaving it as it.
Fix committed to 1.3-stable: 0941377
I will attempt to properly correct the use of translated text as keys in git master.