update-manager crashed with TypeError in _get_last_apt_get_update_text()

Bug #341015 reported by Shahar Or
58
This bug affects 9 people
Affects Status Importance Assigned to Milestone
Python
Won't Fix
Unknown
Software Updater
Fix Released
Undecided
Unassigned
Ubuntu Translations
Invalid
Undecided
Unassigned
language-pack-he (Ubuntu)
Invalid
Undecided
Ubuntu Hebrew Translators
update-manager (Ubuntu)
Fix Released
Undecided
Unassigned

Bug Description

Binary package hint: update-manager

I was telling it to upgrade the dash security upgrade, entered my sudo password, looked away and when I looked back it had already crashed!

ProblemType: Crash
Architecture: i386
DistroRelease: Ubuntu 8.10
ExecutablePath: /usr/bin/update-manager
InterpreterPath: /usr/bin/python2.5
NonfreeKernelModules: ath_hal
Package: update-manager 1:0.93.34
PackageArchitecture: all
ProcAttrCurrent: unconfined
ProcCmdline: /usr/bin/python2.5 /usr/bin/update-manager
ProcEnviron:
 PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
 LANG=he_IL.UTF-8
 SHELL=/bin/bash
PythonArgs: ['/usr/bin/update-manager']
SourcePackage: update-manager
Title: update-manager crashed with TypeError in _get_last_apt_get_update_text()
Uname: Linux 2.6.27-11-generic i686
UserGroups: adm admin cdrom dialout lpadmin plugdev pulse-rt sambashare vboxusers

Revision history for this message
Shahar Or (mightyiam) wrote :
Revision history for this message
Michael Vogt (mvo) wrote :

Thanks for your bugreport.

This is most likely a bug in the translation. Please switch (as a workaround) to the english translation.

The amount of '%s' in the translation of
          return ngettext("The package information was last updated %s hour ago.",
                          "The package information was last updated %s hours ago.",
                          ago_hours) % ago_hours
most likely does not match the original string.

Revision history for this message
Shahar Or (mightyiam) wrote :

I've added new suggestions to the translations of this string in both intrepid and jaunty, which include the correct number of %s.

Kees Cook (kees)
security vulnerability: yes → no
Shahar Or (mightyiam)
tags: added: hebrew
Changed in language-pack-he (Ubuntu):
assignee: nobody → Ubuntu Hebrew Translators (ubuntu-l10n-he)
Revision history for this message
abdullahc (sneetsher) wrote :

I think this bug is coming from python/print function.

As in Arabic,we have 6 plural forms. we used NOT to include the variable (%i for example) in 0th, 1st & 2nd forms. This is the correct language.

I have check both c/printf and python/print. c/printf is more robust.

c/printf accepts this:

n=1;
printf("One hour.", n);

in other hand python/print rises an error:

n=1
print "One hour." % n

As a work around we could do some thing like "(%i) One hour.".

But should we pass this bug to python?

Revision history for this message
Yaron (sh-yaron) wrote : Re: [Ubuntu-l10n-he] [Bug 341015] Re: update-manager crashed with TypeError in _get_last_apt_get_update_text()

Is it truly a python one or is it also gettext related?

Revision history for this message
abdullahc (sneetsher) wrote :

In python; they use this form:

print n_("%i hour.", "%i hours.",n) % n

then it chooses one of the 2 strings if it is English or their translation and replaces n_("%i hour.", "%i hours.",n).

if the result string don't have %i, there will an error in python/print.

Revision history for this message
abdullahc (sneetsher) wrote :

Test this in python console:

i=1
print "%i hour." % i
print "One hour." % i

Revision history for this message
Yaron (sh-yaron) wrote :

I see, I'm not so familiar with python that's why I asked
In this case python bug should be reported
And many thanks in advanced

Revision history for this message
Yaron (sh-yaron) wrote :

I see where you are getting at, but is it a bug or we should suggest a new
feature?

I got:
>>> print "One hour." % i
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: not all arguments converted during string formatting

Revision history for this message
abdullahc (sneetsher) wrote :

It's a bug; As c/printf works well. @#4. Exactly is bug in '%' format operation if not integrated in python/print as in c/printf.

Also it should fixed within python/print we don't have to change all old code.

abdullahc (sneetsher)
Changed in python:
importance: Undecided → Unknown
status: New → Unknown
tags: added: i18n python
Changed in python:
status: Unknown → New
Revision history for this message
abdullahc (sneetsher) wrote :

From: http://bugs.python.org/issue8359 ; This won't be fixed in python % operation.

So we have 2 choices:

- Developers can use str.format() instead of % formatting operation. (a fix)
or
- Translators add the variables even if they are not needed. (a workaround)

Revision history for this message
Yaron (sh-yaron) wrote :

The first option sounds fair enough
Do you have any idea who should we inform?

Revision history for this message
abdullahc (sneetsher) wrote :

It is difficult to inform each developer to use str.format() instead of % formatting operation.

I suggest making a generalized bug. Any one finds similar case can link that tools and packages to it. As 'update-manager' and that one you have told me about 'evolution-indicator'.

Revision history for this message
Yaron (sh-yaron) wrote :

But this one is specifig, if we will find it in any other place we'll report
again and link to this one but until then we will have to battle each
occurrence individually

We'll start with this one

Changed in python:
status: New → Won't Fix
Revision history for this message
David Planella (dpm) wrote :

I've been given a heads up on this bug, but by reading the previous comments, I'm not sure it's fixed. Could someone give an update on the status?

I explained the background on https://bugs.launchpad.net/ubuntu/+source/language-selector/+bug/409785/comments/9 and added another comment on the Python upstream bug about using str.format().

The solution here is that the packages use %-formatting with named arguments (e.g. %(argument) ) to avoid crashes from happening while allowing the languages which require it to discard arguments. If it's not possible to change the code, you should use a workaround in the translation.

If someone could also send a bug report at gettext upstream mentioning the issues with msgfmt I described on the comment from the other bug above, that would also be awesome.

David Planella (dpm)
Changed in ubuntu-translations:
status: New → Incomplete
Revision history for this message
Mohamed Amine Ilidrissi (ilidrissi.amine) wrote :

Is this update-manager's fault? Please respond if you think so.

Changed in update-manager:
status: New → Incomplete
Revision history for this message
Yaron (sh-yaron) wrote : Re: [Ubuntu-l10n-he] [Bug 341015] Re: update-manager crashed with TypeError in _get_last_apt_get_update_text()

This is an apport report, I really can't tell and I never seen it ever
since.

If I remember correct, this bug was plural forms related, instead of
translating: "%d Hour" to "שעה %s", I translated to "שעה אחת" (Which is just
like "One Hour" thus omitting the parameter), I heard they were crashes and
even saw it with my own eyes several times, If I remember correct we
eventually changed back to %d Hour although its not the correct form in
Hebrew...

Can this be fixed?

Robert Roth (evfool)
Changed in update-manager:
status: Incomplete → Confirmed
Changed in language-pack-he (Ubuntu):
status: New → Confirmed
Changed in update-manager (Ubuntu):
status: New → Confirmed
Revision history for this message
Robert Roth (evfool) wrote :

Setting this to fix released, as this does not happen with update-manager on oneiric with translations without parameter placeholders, tried the translations without the %s for the "last updated %s hour" and "last updated %s day" ago strings (singular forms). The translations which do not have the placeholder are : eu, et, he, ar. If you still experience this issue, feel free to reopen this bug by setting its status to new, and describe in a comment the update-manager version you are using, and the output of the locale terminal command.
---
Ubuntu Bug Squad volunteer triager
http://wiki.ubuntu.com/BugSquad

Changed in ubuntu-translations:
status: Incomplete → Fix Released
Changed in update-manager:
status: Confirmed → Fix Released
Changed in ubuntu-translations:
status: Fix Released → Invalid
Changed in language-pack-he (Ubuntu):
status: Confirmed → Invalid
Changed in update-manager (Ubuntu):
status: Confirmed → Fix Released
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.