software-center crashed with UnicodeEncodeError in get_dbus_message(): 'ascii' codec can't encode character u'\xfc' in position 65: ordinal not in range(128)

Bug #846044 reported by Steven Beer
580
This bug affects 88 people
Affects Status Importance Assigned to Milestone
Aptdaemon
Fix Released
Undecided
C.Tenschert
Python Dbus
Fix Released
Medium
aptdaemon (Ubuntu)
Fix Released
Critical
Michael Vogt
Nominated for Precise by Timo Jyrinki
Oneiric
Fix Released
Critical
Michael Vogt
Quantal
Fix Released
Critical
Michael Vogt
dbus-python (Ubuntu)
Fix Released
High
Barry Warsaw
Nominated for Precise by Timo Jyrinki
Oneiric
Won't Fix
High
Michael Vogt
Quantal
Fix Released
High
Barry Warsaw

Bug Description

TEST CASE (for dbus-python):
 1. mkdir /tmp/äää
 2. download google-chrome-stable (or another package that lintian compalins about)
 3. copy deb to /tmp/äää
 4. run software-center /tmp/ää/google-chrome-stable_current_amd64.deb from a terminal
 5. click on "install" and verify that there is a crash in the log that is displayed in the terminal
 6. now install python-dbus from quantal-proposed and restart software-center
 7. verify that the crash is no longer there when repeating step 4

I've tried to install an program. After clicking on "install" and entered password, the software center crashes.

ProblemType: Crash
DistroRelease: Ubuntu 11.10
Package: software-center 4.1.22
ProcVersionSignature: Ubuntu 3.0.0-10.16-generic-pae 3.0.4
Uname: Linux 3.0.0-10-generic-pae i686
NonfreeKernelModules: fglrx
ApportVersion: 1.22.1-0ubuntu2
Architecture: i386
Date: Fri Sep 9 23:31:38 2011
ExecutablePath: /usr/share/software-center/software-center
InstallationMedia: Ubuntu 11.10 "Oneiric Ocelot" - Beta i386 (20110901)
InterpreterPath: /usr/bin/python2.7
PackageArchitecture: all
ProcCmdline: /usr/bin/python /usr/bin/software-center
ProcEnviron:
 PATH=(custom, no user)
 LANG=de_DE.UTF-8
 SHELL=/bin/bash
PythonArgs: ['/usr/bin/software-center']
SourcePackage: software-center
Title: software-center crashed with UnicodeEncodeError in get_dbus_message(): 'ascii' codec can't encode character u'\xfc' in position 65: ordinal not in range(128)
UpgradeStatus: No upgrade log present (probably fresh install)
UserGroups: adm admin cdrom dialout lpadmin plugdev sambashare

Related branches

Revision history for this message
Steven Beer (webneo82) wrote :
tags: removed: need-duplicate-check
Changed in software-center (Ubuntu):
status: New → Confirmed
tags: added: bugpattern-needed
visibility: private → public
Revision history for this message
Daniel Manrique (roadmr) wrote :

Looking at all the duplicate reports, this happens with any language that uses non-ascii characters (those above ASCII 127) - potentially every language but english.

However this only affects a few software packages; I was able to correctly install vlc and flash plugin using a german-language system, but installing mouse trap (the one that controls the mouse with the webcam) fails and reproduces the error.

Steps to reproduce:

0 - I'm using a fully-updated Oneiric installation with software-center 4.1.22.
1 - Install a language that may contain non-ascii characters (the duplicates indicate this may happen in spanish (mexico), portuguese (portugal) and I managed to reproduce it in german (austria)):
   sudo apt-get install language-pack-de language-pack-gnome-de
2- Launch software center from a terminal, using this installed language:
  LANG=de_AT.UTF-8 LANGUAGE=de_AT:de software-center
3- Search for and try to install "mousetrap" (the mouse controlling app, not the game)

Expected result:
- App installs with no errors

Actual result:
- As described in the original report, software center crashes with the given trace.

It looks like somewhere, there is a call to the "unicode" python function, which defaults to using the ascii encoder, so any character in the string to be encoded that can't be encoded as 7-bit ascii will throw the exception.

We saw something similar in bug 833747 and the solution was to explicitly specify the encoder in the call to unicode:

unicode(string,"utf8") instead of unicode(string)

Of course, tracing the actual call to unicode was the tricky part as this is sometimes done implicitly. Also this may cause "secondary effects" and need code changes elsewhere (in bug 833747 we also required some changes to the text sent to a Gtk.TextBuffer to force encoding the unicode into utf8).

I'm setting this bug to triaged and importance: Critical as it has a "severe impact in a large portion of Ubuntu users" - Unreliability and crashes in Software Center, one of Ubuntu's flagship apps, for potentially anyone not on an English locale seems pretty critical to me.

Changed in software-center (Ubuntu):
importance: Undecided → Critical
status: Confirmed → Triaged
Michael Vogt (mvo)
affects: software-center (Ubuntu) → aptdaemon (Ubuntu)
Revision history for this message
Daniel Manrique (roadmr) wrote :

I did a bit more looking into this problem. This gets triggered if a transaction error occurs while trying to install the package. This generates an exception, and it is handling the exception's translated message string that the crash occurs, due to using the ascii codec to encode a unicode that contains characters above code 127. Mousetrap triggers this because it tries to install gnome-mousetrap which has a dependency problem. So I guess the common denominator in packages that trigger this problem is that they all generate an error while installing, due to dependency problems or possibly other factors.

This is visible in the terminal from which software-center is run when trying to install mousetrap:

2011-09-12 12:47:27,097 - softwarecenter.backend - ERROR - error in _on_trans_finished 'Fehler: Die Paketabhängigkeiten können nicht aufgelöst werden
Dieser Fehler könnte durch weitere erforderliche Software-Pakete, die jedoch fehlen oder nicht installiert werden können, verursacht worden sein. Außerdem könnte es einen Konflikt zwischen Paketen geben, die nicht zur selben Zeit installiert sein dürfen.

Die folgenden Pakete haben nicht erfüllte Abhängigkeiten:

gnome-mousetrap: Depends: python (>= 2.6) aber 2.7.2-5ubuntu1 soll installiert werden
                 Depends: python-support (>= 0.90.0) aber 1.0.13ubuntu1 soll installiert werden

Now, I tried setting the default encoding for the system in /usr/lib/python2.7/sitecustomize.py by adding:

import sys
sys.setdefaultencoding('utf8')

If I do this, I still see the above error message, as the dependency problem still remains, but I do not get the UnicodeEncodeError exception that was happening in software-center.

Revision history for this message
lostprophet (matze-spam1) wrote :

i'm not able to install flash-plugin on a german system

Revision history for this message
Sebastian Heinlein (glatzor) wrote :

The error appears on the client side. Hopefully these errors will vanish with a port from dbus to gdbus and python3.

In the meantime we could just workarround this by using the Exception.message attribute which is deprecated.

Revision history for this message
Sebastian Heinlein (glatzor) wrote :

Should be fixed with 697

Changed in aptdaemon (Ubuntu):
status: Triaged → Fix Committed
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package aptdaemon - 0.43+bzr697

---------------
aptdaemon (0.43+bzr697) oneiric; urgency=low

  * New bzr bugfix version:
    - Don't block on lintian calls to avoid time outs on the DBus
      by making use of the excellent preexec_fn of subprocess
      (LP: #812023)
    - pyflakes based import fixes, this fixes a unneeded glib import
      that can cause crashes with gtk2/gtk3 (pygtk/pygi)
    - use the deprecated message attribute to avoid encoding errors
      (LP: #846044)
 -- Michael Vogt <email address hidden> Mon, 19 Sep 2011 14:01:15 +0200

Changed in aptdaemon (Ubuntu):
status: Fix Committed → Fix Released
Michael Vogt (mvo)
Changed in aptdaemon (Ubuntu):
status: Fix Released → In Progress
tags: added: rls-mgr-o-tracking
Revision history for this message
Steve Langasek (vorlon) wrote :

Michael, why has this gone from "fix released" to "in progress"? Is it still in progress for oneiric?

Colin Watson (cjwatson)
Changed in aptdaemon (Ubuntu Oneiric):
assignee: nobody → Michael Vogt (mvo)
Revision history for this message
Michael Vogt (mvo) wrote :

This is fix released, sorry. I set this to in progress before the upload, looks like something was slow or I clicked on it accidentally.

Changed in aptdaemon (Ubuntu Oneiric):
status: In Progress → Fix Released
Revision history for this message
ROCHE (guyroche08-6) wrote :

When installing xsane and "dependence nonsatisfaite" with Fax.
PC HP DV7 2220 SF

Revision history for this message
CSRedRat (csredrat) wrote :

Ubuntu 12.10. This affect me.

Revision history for this message
Nivas (nivas) wrote :

Ubuntu 12.10

Revision history for this message
Sasa Paporovic (melchiaros) wrote :

This bug is reoccuring in Ubuntu12.10 64bit Quantal. Unfortunally launchpad let us not open up a new report, so we must stay here for handling.

tags: added: quantal
Revision history for this message
JOSSE PAUL (pauljosse) wrote : Re: [Bug 846044] Re: software-center crashed with UnicodeEncodeError in get_dbus_message(): 'ascii' codec can't encode character u'\xfc' in position 65: ordinal not in range(128)

Thank you very much !
Le 25 août 2012 14:50, "melchiaros" <email address hidden> a écrit :

> This bug is reoccuring in Ubuntu12.10 64bit Quantal. Unfortunally
> launchpad let us not open up a new report, so we must stay here for
> handling.
>
> ** Tags added: quantal
>
> --
> You received this bug notification because you are subscribed to a
> duplicate bug report (847897).
> https://bugs.launchpad.net/bugs/846044
>
> Title:
> software-center crashed with UnicodeEncodeError in get_dbus_message():
> 'ascii' codec can't encode character u'\xfc' in position 65: ordinal
> not in range(128)
>
> Status in “aptdaemon” package in Ubuntu:
> Fix Released
> Status in “aptdaemon” source package in Oneiric:
> Fix Released
>
> Bug description:
> I've tried to install an program. After clicking on "install" and
> entered password, the software center crashes.
>
> ProblemType: Crash
> DistroRelease: Ubuntu 11.10
> Package: software-center 4.1.22
> ProcVersionSignature: Ubuntu 3.0.0-10.16-generic-pae 3.0.4
> Uname: Linux 3.0.0-10-generic-pae i686
> NonfreeKernelModules: fglrx
> ApportVersion: 1.22.1-0ubuntu2
> Architecture: i386
> Date: Fri Sep 9 23:31:38 2011
> ExecutablePath: /usr/share/software-center/software-center
> InstallationMedia: Ubuntu 11.10 "Oneiric Ocelot" - Beta i386 (20110901)
> InterpreterPath: /usr/bin/python2.7
> PackageArchitecture: all
> ProcCmdline: /usr/bin/python /usr/bin/software-center
> ProcEnviron:
> PATH=(custom, no user)
> LANG=de_DE.UTF-8
> SHELL=/bin/bash
> PythonArgs: ['/usr/bin/software-center']
> SourcePackage: software-center
> Title: software-center crashed with UnicodeEncodeError in
> get_dbus_message(): 'ascii' codec can't encode character u'\xfc' in
> position 65: ordinal not in range(128)
> UpgradeStatus: No upgrade log present (probably fresh install)
> UserGroups: adm admin cdrom dialout lpadmin plugdev sambashare
>
> To manage notifications about this bug go to:
>
> https://bugs.launchpad.net/ubuntu/+source/aptdaemon/+bug/846044/+subscriptions
>

Revision history for this message
C.Tenschert (carl-tenschert) wrote :

error appears after use of this "sudo dpkg -i --force-depends /tmp/fglrx_8.982-0ubuntu1_amd64.deb" in gkonsole

I use --force-depends
because
######
sudo apt-get -f install fglrx
Paketlisten werden gelesen... Fertig
Abhängigkeitsbaum wird aufgebaut.
Statusinformationen werden eingelesen.... Fertig
Probieren Sie »apt-get -f install«, um dies zu korrigieren:
Die folgenden Pakete haben unerfüllte Abhängigkeiten:
 fglrx : Hängt ab von: xorg-video-abi-11
###

xorg-video-abi-11 does not ecist in 12.10

Changed in aptdaemon:
assignee: nobody → C.Tenschert (carl-tenschert)
Changed in aptdaemon:
status: New → Fix Released
Revision history for this message
Marius B. Kotsbak (mariusko) wrote :

Should we open a new bug report for the reappered problem?

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

I opened a quantal task now.

Changed in aptdaemon (Ubuntu Quantal):
status: Fix Released → In Progress
Revision history for this message
Michael Vogt (mvo) wrote :

I can reproduce this with:
$ LANGUAGE=de ./software-center 0ad:i386
and then clicking on "install". With some debug code added I get:

2012-10-08 09:07:52,447 - softwarecenter.backend - WARNING - _on_trans_error: 'UnicodeDecodeError('ascii', 'Transaction failed: Die Paketabh\xc3\xa4ngigkeiten k\xc3\xb6nnen nicht aufgel\xc3\xb6st werden\n', 32, 33, 'ordinal not in range(128)')' '<AptTransaction object at 0x562bdc0 (aptdaemon+client+AptTransaction at 0x2d126e0)>' '0ad:i386'

Revision history for this message
Michael Vogt (mvo) wrote :
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package aptdaemon - 0.45+bzr861-0ubuntu8

---------------
aptdaemon (0.45+bzr861-0ubuntu8) quantal; urgency=low

  * debian/patches/lp846044.patch:
    - fix unicode decode error in py2 clients (LP: #846044)
 -- Michael Vogt <email address hidden> Mon, 08 Oct 2012 15:57:29 +0200

Changed in aptdaemon (Ubuntu Quantal):
status: In Progress → Fix Released
Revision history for this message
CSRedRat (csredrat) wrote :

Happened after reboot. Ubuntu 12.10 Beta 2.

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

There is another releated issue here in dbus-python:

#!/usr/bin/python
# -*- coding: utf-8 -*-
import dbus
e = dbus.exceptions.DBusException(u"bäää")
msg= e.get_dbus_message()

will crash.

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

This is #3 on errors.ubuntu.com right now so we should SRU it once we have a good fix.

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

There is another way to reproduce this in software-center:
1. mkdir /tmp/äää
2. download google-chrome-stable (or another package that lintian compalins about)
3. copy deb to /tmp/äää
4. run software-center /tmp/ää/google-chrome-stable_current_amd64.deb
5. click on "install" and verify that there is a crash in the log

Revision history for this message
In , Michael Vogt (mvo) wrote :

Created attachment 68472
Patch that allows exceptions with unicode error messages

Hi,

I got a crash report releated to unicode for "aptdaemon" and was able to trigger it with the following code fragment.
""""
#!/usr/bin/python
# -*- coding: utf-8 -*-
import dbus
e = dbus.exceptions.DBusException(u"bäää")
msg= e.get_dbus_message()
"""
it would be nice if dbus-python would support that, especially since get_dbus_message() returns a unicode object in py2.

Attached is a patch with testcases that works for me and got a brief
review from Barry Warsaw as well.

I'm happy to adjust the patch as needed, just let me know your thoughts.

Cheers,
 Michael

Revision history for this message
In , Simon McVittie (smcv) wrote :

Comment on attachment 68472
Patch that allows exceptions with unicode error messages

Review of attachment 68472:
-----------------------------------------------------------------

"git format-patch"-formatted patches would be appreciated in future; dbus-python, like all other dbus subprojects, is maintained in git.

Please actually run the tests during "make check". I realise dbus-python's test framework is pretty convoluted: the right place to plug in these tests is test/run-test.sh, near test-standalone.py.

If the tests will compile, but fail, under their non-target version of Python, you could do something like:

    import dbus._compat
    if not dbus._compat.is_py3:
        print "SKIP: not the appropriate Python version"
        raise SystemExit(0)

If they won't even compile under their non-target version of Python, you may have to do something like this:

case `$PYTHON -c "print(__import__('sys').version)"` in
    (2*)
        echo "running test-exception-py2.py"
        $PYTHON "$DBUS_TOP_SRCDIR"/test/test-exception-py2.py || die "... failed"
        ;;
    (3*)
        echo "running test-exception-py3.py"
        $PYTHON "$DBUS_TOP_SRCDIR"/test/test-exception-py3.py || die "... failed"
        ;;
esac

::: test/test-exception-py2.py
@@ +4,5 @@
> +import unittest
> +
> +import dbus
> +
> +class DbusExceptionTestCase(unittest.TestCase):

Pet annoyance: it's spelled "D-Bus", or DBus when you're restricted to C-style identifiers. (Not Dbus or D-BUS.)

@@ +5,5 @@
> +
> +import dbus
> +
> +class DbusExceptionTestCase(unittest.TestCase):
> + """Test the DBusException str/unicode behavior with py2"""

Please also test each case with a subclass of DBusException that sets the _dbus_error_name class member, like ServerError in test-service.py's RaiseDBusException:

        class ServerError(dbus.DBusException):
            """Exception representing a normal "environmental" error"""
            include_traceback = False
            _dbus_error_name = 'com.example.Networking.ServerError'

(Every DBusException raised across D-Bus by an interoperable service should set its _dbus_error_name.)

The most "realistic" version is where isinstance(_dbus_error_name, str), whatever that means in this Python version. I don't think anyone deliberately sets it to a unicode in Python 2 or a bytestring in Python 3.

The expected result is that get_dbus_message() will still return "baaa", but str() and unicode() will return something more like "com.example.Networking.ServerError: baaa".

::: test/test-exception-py3.py
@@ +8,5 @@
> +class DbusExceptionTestCase(unittest.TestCase):
> +
> + def test_dbus_exception(self):
> + e = dbus.exceptions.DBusException("bäää")
> + msg= e.get_dbus_message()

Coding style: msg = e...

As in the Python 2 case, please test that unicode(e) also works and gives the desired result.

As in the Python 2 case, please also test with a subclass that sets _dbus_error_name.

Revision history for this message
In , Michael Vogt (mvo) wrote :

Created attachment 68486
Updated

Thanks for your patch review.

The attached version should address the points you raised:
- it uses git format-patch
- integrates into make check
- fixes the DBus spelling
- add ServerError(dbus.DBusException) based test
- fix coding style
- add missing cases for the py3 test

Please let me know if I missed anything.

Michael Vogt (mvo)
Changed in dbus-python (Ubuntu Oneiric):
status: New → In Progress
importance: Undecided → High
Changed in dbus-python (Ubuntu Quantal):
status: New → In Progress
importance: Undecided → High
Changed in dbus-python (Ubuntu Oneiric):
assignee: nobody → Michael Vogt (mvo)
Revision history for this message
Steve Langasek (vorlon) wrote :

Barry, can you offer any assistance here? I guess you might be familiar with the encoding handling in the dbus-python code in question :)

Changed in dbus-python (Ubuntu Quantal):
assignee: nobody → Barry Warsaw (barry)
milestone: none → quantal-updates
Revision history for this message
Barry Warsaw (barry) wrote :

On Oct 16, 2012, at 12:36 AM, Steve Langasek wrote:

>Barry, can you offer any assistance here? I guess you might be familiar
>with the encoding handling in the dbus-python code in question :)

Michael already did all the hard work of figuring out a patch. I reviewed it
and suggested he send it upstream, which he did, and got further comments from
the upstream maintainer. Michael posted an updated patch to the upstream
issue.

I think it is worth fixing for Quantal, although IIRC, Michael has a
workaround for software-center. In any case, since you targeted the bug task
to quantal-updates, I'll prepare a patch for quantal-proposed (testing it
now).

Revision history for this message
In , Barry Warsaw (barry) wrote :

One quick question about this test:

+ def test_dbus_exception_convert_str_fail(self):
+ """Test that a non-ascii Exception fails to convert to str"""
+ with self.assertRaises(ValueError):
+ e = dbus.exceptions.DBusException(u"bä")
+ print str(e)

Are you sure you get a ValueError here and not a UnicodeEncodeError?

Python 2.7.3 (default, Sep 26 2012, 21:51:14)
[GCC 4.7.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> a = u'b\xe4\xe4\xe4'
>>> print a
bäää
>>> import dbus.exceptions
>>> x = dbus.exceptions.DBusException(a)
>>> str(x)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
UnicodeEncodeError: 'ascii' codec can't encode characters in position 1-3: ordinal not in range(128)

Revision history for this message
Barry Warsaw (barry) wrote :

dbus-python (1.1.1-1ubuntu1) quantal-proposed; urgency=low

  * debian/patches/fdo-bug-55899.patch: Apply upstream patch for upstream
    bug 55899, support for Unicode DBusExceptions in Python 2.
    (LP: #846044)

 -- Barry Warsaw <email address hidden> Tue, 16 Oct 2012 10:04:27 -0400

Revision history for this message
In , Michael Vogt (mvo) wrote :

Thanks Barry - you are right, its a UnicodeEncodeError, its a subclass of a ValueError this is why the test works. I can update the test (I guess that is actually the right thing to do).

How is the patch looking otherwise? Sorry for rushing a bit but this is a relatively common error for my application so it would be great to have a fix :)

Revision history for this message
Simon McVittie (smcv) wrote :

Saying "Apply upstream patch" is rather misleading when I haven't merged it yet (because it fails the upstream regression tests)...

Revision history for this message
In , Simon McVittie (smcv) wrote :

This appears to be LP#846044. It would be nice if you'd mentioned that.

Unfortunately, this patch causes some regressions. I can tell you didn't run 'make check', because when I did, it caught them...

Without the patch:

>>> import dbus
>>> e = dbus.DBusException('bees')
>>> e._dbus_error_name = 'com.example.Badness'
>>> str(e)
'com.example.Badness: bees'

With it (same preparation steps):

>>> str(e)
'bees'

Fixed in the fdo55899 branch in:

    git://people.freedesktop.org/~smcv/dbus-python

Please review, re-test. cgit at <http://cgit.freedesktop.org/~smcv/dbus-python/log/?h=fdo55899> when it gets round to refreshing.

Revision history for this message
In , Simon McVittie (smcv) wrote :

Created attachment 68627
Support unicode messages for DBusException in Python 2

[commit message amended -smcv]

Revision history for this message
In , Simon McVittie (smcv) wrote :

Created attachment 68628
Skip test_dbus_exception_convert_str_fail under unusual default encodings

This would actually work fine if the default encoding was UTF-8 or
Latin-1 or something.

Revision history for this message
In , Simon McVittie (smcv) wrote :

Created attachment 68629
Use a form of assertRaises() that works in Python 2.6

Revision history for this message
In , Simon McVittie (smcv) wrote :

Created attachment 68630
Slightly better test coverage

Revision history for this message
In , Simon McVittie (smcv) wrote :

Created attachment 68631
DBusException: override both __str__ and __unicode__

Avoid chaining up to the superclass, because that behaves particularly
oddly. This fixes regression test failures: str(some_dbus_exception) was no
longer prefixed with the D-Bus error name under Python 2.

Revision history for this message
Barry Warsaw (barry) wrote :

On Oct 16, 2012, at 05:19 PM, Simon McVittie wrote:

>Saying "Apply upstream patch" is rather misleading when I haven't merged
>it yet (because it fails the upstream regression tests)...

I'll fix the commit message (unless you make it true by the time I re-upload
it ;). In the meantime, I thought I did see a passing test suite, but I tried
it again in a clean tree to be sure, and indeed, I see the regressions too. I
asked the release team to reject my upload, which they've done. I'll respin
that once we have a patch that you like.

Revision history for this message
In , Barry Warsaw (barry) wrote :

After applying all 5 patches, the test suite passes for me in both Python 2.7 and 3.2 on Ubuntu 12.10.

Visual review of the patches:

* I'm not sure that you need the lambda in test_dbus_exception_convert_str_fail(). It looks weird but I haven't tried it without the lambda.

* Can you provide some more detail about the weird up-chaining you're seeing with Exception.__unicode__?

* I'd probably swap this code around (I always dislike testing a negative when testing a positive will do just as well):

+ if self._dbus_error_name is not None:
+ return '%s: %s' % (self._dbus_error_name, s)
+ else:
+ return s

i.e.

if self._dbus_error_name is None:
    return s
else:
    return '%s: %s' % (self._dbus_error_name, s)

Revision history for this message
In , Michael Vogt (mvo) wrote :

Hello Simon,

sorry about the regression my patch caused (and the lack of referencing LP: #846044 directly). I did run make check to ensure that my new part of the testsuite is executed but failed to see the regression. My mistake.

I used ~smcv/dbus-python and commit d262628e89115bbcc33c439c77d33733c4a23491
to build a dbus-python 1.1.1.1-0ubuntu1 test deb and ran the test I outlined
in https://bugs.launchpad.net/ubuntu/quantal/+source/dbus-python/+bug/846044/comments/24. This works fine when using your branch and without it fails with
UnicodeEncodeError. The testsuite is also fine for me on both 2.7 and 3.2 now.

So from my POV this is fine. Thanks a lot!

Cheers,
 Michael

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

Thanks Barry and Simon!

I pushed a branch based on the latest fixes from Simon here:
  lp:~mvo/ubuntu/quantal/dbus-python/lp846044

Once that is merged upstream we should upload it (and/or adept if the final commit has changes too).

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

Unfortunately the workaround in software-center is not enough so we should fix this here would make software-center
get off #5 from errors.ubuntu.com for quantal :)

Revision history for this message
Barry Warsaw (barry) wrote :

On Oct 17, 2012, at 07:37 AM, Michael Vogt wrote:

>Thanks Barry and Simon!
>
>I pushed a branch based on the latest fixes from Simon here:
> lp:~mvo/ubuntu/quantal/dbus-python/lp846044

Mine is at lp:~barry/ubuntu/quantal/dbus-python/lp846044

I haven't looked yet, but I'm guessing they're going to be functionally
equivalent.

>Once that is merged upstream we should upload it (and/or adept if the
>final commit has changes too).

+1

Michael Vogt (mvo)
Changed in dbus-python (Ubuntu Oneiric):
status: In Progress → Won't Fix
Changed in python-dbus:
importance: Unknown → Medium
status: Unknown → Confirmed
Revision history for this message
In , Simon McVittie (smcv) wrote :

I've applied those patches. Fixed in git for 1.1.2, unless you spot any further problems.

(In reply to comment #11)
> * I'm not sure that you need the lambda in
> test_dbus_exception_convert_str_fail().

You do. In the older form of assertRaises, the thing that raises the exception needs to be a callable, so that the exception isn't already raised before it has a chance to wrap it in a "try:".

This is much nicer in the newer form, but I don't think that's a good enough reason to require Python 2.7.

> * Can you provide some more detail about the weird up-chaining you're seeing
> with Exception.__unicode__?

It's really BaseException.__unicode__, which is this pseudocode:

    if self.__str__ isn't BaseException.__str__:
        return unicode(self.__str__()) # <---------

    if len(self.args) == 0:
        return ""

    if len(self.args) == 1:
        return unicode(self.args[0])

    # len(self.args) > 1
    return unicode(self.args)

The __str__ call will raise an exception if the message is non-ASCII but the default codec is ASCII, so we lose.

My implementation of __unicode__ is a slightly more concise version of the rest of that pseudocode - I'm essentially emulating what would happen if we didn't have a __str__ method at all. We need __str__ for Python 3, AIUI.

> * I'd probably swap this code around (I always dislike testing a negative
> when testing a positive will do just as well):
>
> + if self._dbus_error_name is not None:
> + return '%s: %s' % (self._dbus_error_name, s)
> + else:
> + return s

It was already like that, and I tend to think of "is not None" as the "positive" case - conceptually, I'm saying "if there is a _dbus_error_name". I'd accept a patch to change both copies if you feel strongly about this, though.

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

I uploaded this now to quantal-proposed.

description: updated
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package dbus-python - 1.1.1-1ubuntu1

---------------
dbus-python (1.1.1-1ubuntu1) raring; urgency=low

  * merge lp:~barry/ubuntu/quantal/dbus-python/lp846044
    (LP: #846044)
 -- Michael Vogt <email address hidden> Mon, 05 Nov 2012 09:12:51 +0100

Changed in dbus-python (Ubuntu):
status: In Progress → Fix Released
Revision history for this message
Clint Byrum (clint-fewbar) wrote :

Hello! Unfortunately because this was accepted in raring first, we can't accept 1.1.1-1ubuntu1 into quantal (we can copy forward, but not backward AFAIK).

So, please re-upload to quantal-proposed with a version of 1.1.1-1ubuntu0.1

Changed in dbus-python (Ubuntu Quantal):
status: In Progress → Fix Committed
status: Fix Committed → In Progress
Revision history for this message
Barry Warsaw (barry) wrote : Re: [Bug 846044] Re: software-center crashed with UnicodeEncodeError in get_dbus_message(): 'ascii' codec can't encode character u'\xfc' in position 65: ordinal not in range(128)

On Nov 07, 2012, at 10:19 PM, Clint Byrum wrote:

>Hello! Unfortunately because this was accepted in raring first, we can't
>accept 1.1.1-1ubuntu1 into quantal (we can copy forward, but not
>backward AFAIK).
>
>So, please re-upload to quantal-proposed with a version of
>1.1.1-1ubuntu0.1

Yep, saw that. No problem.

Revision history for this message
Barry Warsaw (barry) wrote :

1.1.1-1ubuntu0.1 uploaded to quantal-proposed.

Revision history for this message
Brian Murray (brian-murray) wrote : Please test proposed package

Hello Steven, or anyone else affected,

Accepted dbus-python into quantal-proposed. The package will build now and be available at http://launchpad.net/ubuntu/+source/dbus-python/1.1.1-1ubuntu0.1 in a few hours, and then in the -proposed repository.

Please help us by testing this new package. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation how to enable and use -proposed. Your feedback will aid us getting this update out to other Ubuntu users.

If this package fixes the bug for you, please change the bug tag from verification-needed to verification-done. If it does not, change the tag to verification-failed. In either case, details of your testing will help us make a better decision.

Further information regarding the verification process can be found at https://wiki.ubuntu.com/QATeam/PerformingSRUVerification . Thank you in advance!

Changed in dbus-python (Ubuntu Quantal):
status: In Progress → Fix Committed
tags: added: verification-needed
Revision history for this message
Matthew Paul Thomas (mpt) wrote :

This is the #2 most frequent recorded error for all Ubuntu users in the past day, and #4 for the past month.

Revision history for this message
Timo Jyrinki (timo-jyrinki) wrote :

I can confirm that the quantal update in -proposed fixes this for me.

tags: added: verification-done
removed: verification-needed
Revision history for this message
Colin Watson (cjwatson) wrote : Update Released

The verification of this Stable Release Update has completed successfully and the package has now been released to -updates. Subsequently, the Ubuntu Stable Release Updates Team is being unsubscribed and will not receive messages about this bug report. In the event that you encounter a regression using the package from -updates please report a new bug using ubuntu-bug and tag the bug report regression-update so we can easily find any regresssions.

Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package dbus-python - 1.1.1-1ubuntu0.1

---------------
dbus-python (1.1.1-1ubuntu0.1) quantal-proposed; urgency=low

  * debian/patches/fdo-bug-55899.patch: Support Unicode DBusExceptions
    in Python 2. (LP: #846044)
 -- Barry Warsaw <email address hidden> Tue, 16 Oct 2012 15:25:00 -0400

Changed in dbus-python (Ubuntu Quantal):
status: Fix Committed → Fix Released
Revision history for this message
Brian Murray (brian-murray) wrote :

Looking at the error page for this problem:

https://errors.ubuntu.com/bucket/?id=%2Fusr%2Fshare%2Fsoftware-center%2Fsoftware-center%3AUnicodeEncodeError%3Amsg_reply_handler%3A%3Clambda%3E%3Aget_native_exception%3Aget_dbus_message

It appears that very few Precise users are affected by this, as such I don't believe this is worth fixing in Precise at this point in time.

Revision history for this message
Timo Jyrinki (timo-jyrinki) wrote :

Right, I can't access the page but it seems the it's more oneiric era bug.

Changed in python-dbus:
status: Confirmed → Fix Released
To post a comment you must log in.