Opened 11 years ago

Closed 10 years ago

#979 closed defect (fixed)

Browse activity does not start if LANG=C

Reported by: cyberorg Owned by: erikos
Priority: Unspecified by Maintainer Milestone: Unspecified
Component: Browse Version: Unspecified
Severity: Unspecified Keywords: r+
Cc: Distribution/OS: Unspecified
Bug Status: Unconfirmed

Description

Works fine if LANG=en_US.UTF-8 or something else like that.

tail -f /home/linux/.sugar/default/logs/org.laptop.WebActivity-1.log

main.main()

File "/usr/lib/python2.6/site-packages/sugar/activity/main.py", line 140, in main

create_activity_instance(activity_constructor, activity_handle)

File "/usr/lib/python2.6/site-packages/sugar/activity/main.py", line 34, in create_activity_instance

activity = constructor(handle)

File "/usr/share/sugar/activities/Browse.activity/webactivity.py", line 190, in init

_set_accept_languages()

File "/usr/share/sugar/activities/Browse.activity/webactivity.py", line 146, in _set_accept_languages

and lang[2] != "_":

IndexError: string index out of range

Attachments (1)

sugar-979.patch (1.4 KB) - added by alsroot 10 years ago.

Download all attachments as: .zip

Change History (6)

comment:1 Changed 11 years ago by gdesmott

I can confirm this bug with an up to date sugar-emulator instance.

Changed 10 years ago by alsroot

comment:2 Changed 10 years ago by alsroot

  • Keywords r? added

comment:3 follow-up: Changed 10 years ago by sascha_silbe

  • Distribution/OS changed from openSUSE to Unspecified

Does the patch actually work?
I noticed a few issues:

  1. locale.setlocale() is not called. From the locale.getdefaultlocale() documentation:

According to POSIX, a program which has not called setlocale(LC_ALL, "") runs using the portable 'C' locale. Calling setlocale(LC_ALL, "") lets it use the default locale as defined by the LANG variable. Since we don't want to interfere with the current locale setting we thus emulate the behavior in the way described above.

  1. lang.split('_') returns a list with one element for lang='C', so lang[1] would cause an IndexError.

comment:4 in reply to: ↑ 3 Changed 10 years ago by alsroot

Replying to sascha_silbe:

Does the patch actually work?

at least for me

I noticed a few issues:

  1. locale.setlocale() is not called. From the locale.getdefaultlocale() documentation:

According to POSIX, a program which has not called setlocale(LC_ALL, "") runs using the portable 'C' locale. Calling setlocale(LC_ALL, "") lets it use the default locale as defined by the LANG variable. Since we don't want to interfere with the current locale setting we thus emulate the behavior in the way described above.

I guess python does it otherwise gettext shouldn't work at all
anyway locale.getdefaultlocale() returns right value

  1. lang.split('_') returns a list with one element for lang='C', so lang[1] would cause an IndexError.

for LANG=C, locale.getdefaultlocale() returns (None, None), so lang.split('_') doesn't start at all

comment:5 Changed 10 years ago by erikos

  • Keywords r+ added; r? removed
  • Resolution set to fixed
  • Status changed from new to closed

Thanks for the patch and for your testing. Pushed to master, just in time ;p

Note: See TracTickets for help on using tickets.