Comment 36 for bug 846044

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)