unable to remove an account under certain locales

Bug #363384 reported by Steve Dodier-Lazaro
10
This bug affects 1 person
Affects Status Importance Assigned to Milestone
wxBanker
Fix Released
Medium
Michael Rooney

Bug Description

The "delete selected account" button doesn't seem to work at all.

See the log from console :

steve@steve-laptop:~$ wxbanker

Traceback (most recent call last):
  File "/usr/lib/python2.5/site-packages/wxbanker/accountlistctrl.py", line 443, in onRemoveButton
    dlg = wx.MessageDialog(self, warningMsg%account.Name, _("Warning"), style=wx.YES_NO|wx.ICON_EXCLAMATION)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 9: ordinal not in range(128)

Revision history for this message
Steve Dodier-Lazaro (sidi) wrote :

I tracked the issue down a little and i found where the bug was coming from :

Python fails to parse the string that should be written in the popup, because it's encoding isn't set, which makes Python use the ASCII encoding. And unfortunately, languages such as french have characters outside of ASCII.

The application should be set to UTF-8 in order to fix this kind of problems.

Changed in wxbanker:
status: New → Confirmed
Revision history for this message
Michael Rooney (mrooney) wrote : Re: [Bug 363384] Re: Delete account button doesn't work

Thanks for the report. I guess I need to be more defensive and figure
out where to explicitly encode to perhaps utf-8. One challenge is that
utf-8 might not always be the right encoding; I am not quite sure how
to detect this.

Revision history for this message
Steve Dodier-Lazaro (sidi) wrote : Re: Delete account button doesn't work

UTF-8 supports almost every alphabet of the world, and i think it's the one used by default everywhere. I don't know either about how to detect it, but the default definately shouldn't be ANSI, which is only suitable for english characters :)

Revision history for this message
Steve Dodier-Lazaro (sidi) wrote :

This patch seems to solve the issue here, related to the way the attention strings are translated. I also seem to be able to create and delete accounts with UTF-8 names.

Changed in wxbanker:
status: Confirmed → Fix Committed
Revision history for this message
Michael Rooney (mrooney) wrote :

If all you do is change the single quotes to double quotes it works, but this is only because there is no longer a translation for that string :) So, I don't think that patch would actually address the issue; I suspect if there was a translation for that new string it would do the same thing.

Changed in wxbanker:
importance: Undecided → Medium
milestone: none → 0.5
status: Fix Committed → In Progress
Revision history for this message
Michael Rooney (mrooney) wrote :

Okay fixed as of r224. After asking in #python I just need to add a .decode("utf-8") to the translated warningMsg before formatting with the account.Name. Thanks again for this catch!

Changed in wxbanker:
assignee: nobody → Michael Rooney (mrooney)
status: In Progress → Fix Committed
summary: - Delete account button doesn't work
+ unable to remove an account under certain locales
Revision history for this message
Steve Dodier-Lazaro (sidi) wrote :

Well, it's been a long walk :)

I actually tried unicode(AccountName, UTF8) but it wasn't working here, saying it couldn't be parsed to UTF8.

The fix works here too !

Revision history for this message
Karel Kolman (kolmis) wrote :

Michael, wouldn't it be better to tell gettext to always return unicode strings ?

i.e. replace

gettext.install(APP, DIR)
with
gettext.install(APP, DIR, unicode=True)

in localization.py, that way _() calls gettext.ugettext() method.

Revision history for this message
Michael Rooney (mrooney) wrote :

Thanks for the suggestion Karel, let me investigate that. That might be a better solution indeed!

Changed in wxbanker:
status: Fix Committed → In Progress
Revision history for this message
Michael Rooney (mrooney) wrote :

Thanks Karel, that works indeed, I will use that approach instead!

Changed in wxbanker:
status: In Progress → Fix Committed
Revision history for this message
Steve Dodier-Lazaro (sidi) wrote :

Now having trouble with the "Send to calculator" due to the new french translation.

Changed in wxbanker:
status: Fix Committed → In Progress
Revision history for this message
Michael Rooney (mrooney) wrote :

Since this bug was originally about just removing an account and was targeted for 0.5 and fixed, I'll mark it as such. Steve, does the calculator bug still exist? If so let's make a new bug and target for 0.6.

Changed in wxbanker:
status: In Progress → Fix Released
Revision history for this message
Michael Rooney (mrooney) wrote :

I confirmed it and created https://bugs.launchpad.net/wxbanker/+bug/375308. Karel, maybe you know the way to fix it. In the description I mention that wrapping the return of float2str calls in unicode seems good, and fixes the issue, but fails a test with the traceback given. Hmm!

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Bug attachments

Remote bug watches

Bug watches keep track of this bug in other bug trackers.