gnome-language-selector crashed with TypeError in check_status()

Bug #409785 reported by David Planella
54
This bug affects 8 people
Affects Status Importance Assigned to Milestone
Ubuntu Translations
Fix Released
High
Unassigned
language-selector (Ubuntu)
Fix Released
High
Colin Watson
Karmic
Fix Released
High
Colin Watson

Bug Description

Binary package hint: language-selector

gnome-language-selector crashed with the attached stacktrace while testing Arabic language support

ProblemType: Crash
Architecture: i386
Date: Tue Aug 4 19:25:22 2009
DistroRelease: Ubuntu 9.10
ExecutablePath: /usr/bin/gnome-language-selector
InterpreterPath: /usr/bin/python2.6
Package: language-selector 0.4.6
PackageArchitecture: all
ProcCmdline: /usr/bin/python /usr/bin/gnome-language-selector
ProcEnviron:
 LANGUAGE=ar_LY.UTF-8
 LANG=ar_LY.UTF-8
 SHELL=/bin/bash
ProcVersionSignature: Ubuntu 2.6.31-5.24-generic
PythonArgs: ['/usr/bin/gnome-language-selector']
SourcePackage: language-selector
Title: gnome-language-selector crashed with TypeError in check_status()
Uname: Linux 2.6.31-5-generic i686
UserGroups: adm admin cdrom dialout lpadmin plugdev sambashare

Revision history for this message
David Planella (dpm) wrote :
tags: removed: need-duplicate-check
Revision history for this message
Ara Pulido (ara) wrote :

This is happening to me as well, in Karmic alternate 20091020

Changed in language-selector (Ubuntu):
status: New → Confirmed
visibility: private → public
Steve Langasek (vorlon)
Changed in language-selector (Ubuntu Karmic):
importance: Undecided → High
milestone: none → ubuntu-9.10
status: Confirmed → Triaged
David Planella (dpm)
Changed in ubuntu-translations:
importance: Undecided → High
Revision history for this message
David Planella (dpm) wrote :

This is due to translations of plurals not including the %d variables from the original string.

Launchpad should be in general checking this, but I've filed bug 456210 in case it doesn't do it in all cases.

I've also contacted the Arabic translator to fix them in Launchpad, but in the meantime I've demoted the translations to suggestions so that at least they will not be included in the next language pack export to avoid the crash.

Colin Watson (cjwatson)
Changed in language-selector (Ubuntu Karmic):
assignee: nobody → Colin Watson (cjwatson)
status: Triaged → Fix Committed
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package language-selector - 0.4.16

---------------
language-selector (0.4.16) karmic; urgency=low

  * Add --show-installed option to check-language-support, so that ubiquity
    can arrange to keep language support packages installed that are already
    present in the live filesystem.
  * Enable translation for check-language-support.
  * Mark Arabic translations of "%d to install" and "%d to remove" as fuzzy,
    until such time as they're corrected in Launchpad (LP: #409785).
  * ... and likewise for Hebrew (LP: #363990).

 -- Colin Watson <email address hidden> Tue, 20 Oct 2009 13:02:27 +0100

Changed in language-selector (Ubuntu Karmic):
status: Fix Committed → Fix Released
Revision history for this message
Khaled Hosny (khaledhosny) wrote :

This isn't a translation bug but rather language-selector's bug. The aforementioned strings are valid strings and are used throughout Arabic gnome l10n. Changing the translation is no option.

Revision history for this message
Colin Watson (cjwatson) wrote : Re: [Bug 409785] Re: gnome-language-selector crashed with TypeError in check_status()

On Tue, Oct 20, 2009 at 11:21:37PM -0000, Khaled Hosny wrote:
> This isn't a translation bug but rather language-selector's bug. The
> aforementioned strings are valid strings and are used throughout Arabic
> gnome l10n. Changing the translation is no option.

Do you mean that some of the strings are the equivalent of "none to
install" rather than "0 to install", or something along those lines?
This relies on a feature of C's printf function (discarding excess
arguments) which is not present in the natural Python equivalent. It's
possible to emulate it, I'm sure, but it will take some work.

I would suggest that you be very careful when using this style in
strings tagged python-format: this is an explicit warning that this
approach may cause application failures.

Revision history for this message
Khaled Hosny (khaledhosny) wrote :

Yes, it is kind of like "non to install" but more complex that it can't be simply replaced by "0 to install" without some really ugly and poor translation.

Colin Watson (cjwatson)
Changed in language-selector (Ubuntu Karmic):
status: Fix Released → Triaged
Colin Watson (cjwatson)
Changed in language-selector (Ubuntu Karmic):
status: Triaged → Fix Committed
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package language-selector - 0.4.18

---------------
language-selector (0.4.18) karmic; urgency=low

  * Use dictionary-based format string substitution for "%d to install" and
    "%d to remove" (now "%(INSTALL)d to install" and "%(REMOVE)d to
    remove"), so that gnome-language-selector doesn't crash when a
    translation intentionally uses fixed strings for some of its plural
    forms (LP: #409785).
  * Remove fuzzy markers on the respective Arabic and Hebrew translations
    (see 0.4.16) since they no longer cause a crash.

 -- Colin Watson <email address hidden> Fri, 23 Oct 2009 18:50:30 +0100

Changed in language-selector (Ubuntu Karmic):
status: Fix Committed → Fix Released
David Planella (dpm)
Changed in ubuntu-translations:
status: New → Fix Released
tags: added: iso-testing
Revision history for this message
David Planella (dpm) wrote :

Sorry to comment on a closed bug, but I just wanted to mention this here for the record.

* In C, due to what Colin was mentioning, that is, the ability to discard named arguments in format strings, you can translate plurals such as:

#, c-format
msgid "%d package"
msgid_plural "%d packages"
msgstr[0] "one package"
msgstr[1] "%d packages"

This will work in the program and "msgfmt --check" won't show any errors

* In Python, you cannot do this. Python supports unnamed (e.g. %d) and named (e.g. %(package)d) arguments in format strings. With unnamed arguments, Python verifies that all of the arguments are being used.

#, python-format
msgid "%d package"
msgid_plural "%d packages"
msgstr[0] "one package"
msgstr[1] "%d packages"

This will cause a program crash. However, "msgfmt --check" won't show any errors either. That's why Launchpad does not detect these errors, since it uses the standard gettext tools for error-checking.

The workaround to this in the code is simply to use always named arguments for plurals in Python.

For translators, this means that they can translate the following without causing a program crash:

#, python-format
msgid "%(package)d package"
msgid_plural "%(package)d packages"
msgstr[0] "one package"
msgstr[1] "%(package)d packages"

For developers to implement this, they can use something like:

gettext.ngettext("%(package)d package", "%(package)d packages", countInstall) % { 'package': countInstall}

instead of:

gettext.ngettext("%d package", "%d packages", countInstall) % countInstall

This also offers the benefit that if there are several arguments in the same string, naming them permits rearranging them in the translation, which is otherwise not possible in Python.

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

Duplicates of this bug

Other bug subscribers

Remote bug watches

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