Exceptions and unicode messages

T

Tuomas

This works:Traceback (most recent call last):
File "<stdin>", line 1, in ?
StandardError: Wrong type

but don't in Finnish:Traceback (most recent call last):

Any solution in Python?

TV
 
K

kyosohma

This works:
Traceback (most recent call last):
File "<stdin>", line 1, in ?
StandardError: Wrong type

but don't in Finnish:
Traceback (most recent call last):


Any solution in Python?

TV

When I do this, mine says "StandardError: <unprintable StandardError
object>" on both Python 2.4 and 2.5. I tried setting them to unicode,
but that didn't help. One way around this may be to subclass the
errors you want and do some custom processing that way.

Mike
 
T

Tuomas

This seems to work:
.... if tb:
.... lines = traceback.format_tb(tb)
.... for i, line in zip(range(len(lines)), lines):
.... lines = lines.decode('utf8')
.... lines.insert(0, u'Traceback (most recent call last):\n')
.... else:
.... lines = []
.... msg = str(exctype).split('.')[-1] + u': ' + unicode(value)
.... lines.append(msg)
.... print u''.join(lines)
........ def __str__(self):
.... return self.args[0]
....Traceback (most recent call last):

Tuomas
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

Forum statistics

Threads
474,431
Messages
2,571,679
Members
48,796
Latest member
Greg L.

Latest Threads

Top