Commit 5543cfe6 authored by Guillaume Risbourg's avatar Guillaume Risbourg Committed by Vincent A

[weboob/exceptions] Replace BrowserQuestion __str__ with __unicode__

Currently in python 2 if we try to print a BrowserQuestion that has a
unicode message, it crash with the error UnicodeEncodeError or
UnicodeDecodeError. This can be fixed by using the __unicode__ from
StrConv.
parent 36b7cfef
......@@ -18,6 +18,10 @@
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
from weboob.tools.misc import to_unicode
from weboob.tools.compat import StrConv
class BrowserIncorrectPassword(Exception):
pass
......@@ -38,7 +42,7 @@ class BrowserInteraction(Exception):
pass
class BrowserQuestion(BrowserInteraction):
class BrowserQuestion(BrowserInteraction, StrConv):
"""
When raised by a browser,
"""
......@@ -50,9 +54,12 @@ class BrowserQuestion(BrowserInteraction):
field.id or field.label, field.description) for field in self.fields
)
def __str__(self):
return ", ".join("{}: {}".format(
field.id or field.label, field.description) for field in self.fields
def __unicode__(self):
return ", ".join(
u"{}: {}".format(
to_unicode(field.id) or to_unicode(field.label),
to_unicode(field.description)
) for field in self.fields
)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment