Ticket #979 (closed defect: fixed)

Opened 4 years ago

Last modified 4 years ago

Browse activity does not start if LANG=C

Reported by: cyberorg Owned by: erikos
Priority: Unspecified by Maintainer Milestone: Unspecified by Release Team
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

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

Change History

  Changed 4 years ago by gdesmott

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

Changed 4 years ago by alsroot

  Changed 4 years ago by alsroot

  • keywords r? added

follow-up: ↓ 4   Changed 4 years ago by sascha_silbe

  • distribution 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.

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

in reply to: ↑ 3   Changed 4 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

2. 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

  Changed 4 years ago by erikos

  • keywords r+ added; r? removed
  • status changed from new to closed
  • resolution set to fixed

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

Note: See TracTickets for help on using tickets.