software-center crashes on locale without underscore

Bug #1535620 reported by Renardo
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
software-center (Ubuntu)
New
Undecided
Unassigned

Bug Description

I am running Ubuntu 15.10. Some time ago software-center (13.10-0ubuntu12) started to crash on the first launch during a session. It turned out that software-center tries to determine a country code from the locale data (region.py, line 114, in _get_region_dumb) by splitting the locale at the underscore. My locale ("eo.utf8") does not contain an underscore.

A second launch usually succeeds; I suppose there is another way of getting the country information (_get_region_geoclue?). I have no idea what the country information is used for, so I would rather not hack it.

In my opinion programs should not depend on an underscore in the locale.

Renardo (renardo)
affects: ubuntu → software-center (Ubuntu)
Revision history for this message
Renardo (renardo) wrote :

As m-hampl (in question 281095) pointed out the problem affects the "C" locale, too, as it does not contain an underscore either.

It might be useful to describe why software-center needs the country, so as to decide whether it is legal to provide a dummy country (to circumvent the problem).

Renardo (renardo)
description: updated
Revision history for this message
Renardo (renardo) wrote :

I just corrected Ubuntu 5.10 to 15.10 in my description. Sorry.

I could not find where the LOGging of software-center goes so I put in a couple of print statements and found the following:

* On the first call of software-center after system boot I get an "org.freedesktop.Geoclue.Error.notAvailable: Geoclue master client has no usable Address providers". The script falls back to _get_region_dumb(), which fails for lack of an underscore in the locale.
* On the second call, client.GetAddress() returns rather detailed location information, of which the country code is used.

So, the first problem is, why does the Geoclue call fail on first try and succeed on second.

The second problem is, what can my system use as a fallback, given there is no country information in my locale. For this I need to know what the country is used for.

Since nobody here seems to know the answer I dug through a bit of code and found the following comment (in categories.py):

   """ this build the dict used to substitute menu entries dynamically,
               currently used for the CURRENT_REGION

The country code is put into a dictionary (_template_dict) under the key CURRENT_REGION. It is then used to make substitutions in many strings ("Utility", "Accessibility", "Settings", etc), none of which, however, seems at present to contain the CURRENT_REGION key.

I conclude that it is safe for me to use an empty country code as fallback, by putting the following check into _get_region_dumb():

    if not '_' in loc:
        return res

I still suggest that this is a bug and should be fixed.

Renardo (renardo)
description: updated
Revision history for this message
Renardo (renardo) wrote :

The issue seems to have been fixed by a try-catch; I now just get a warning "Failed to get locale: 'list index out of range'". If this was an official patch I confirm that my test was positive.

Moreover, since Ubuntu 16.04 software-center has been replaced by gnome-software, so I guess this bug may be safely closed.

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

Other bug subscribers

Remote bug watches

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