Possible bug?

27 views
Skip to first unread message

cosmos

unread,
Aug 17, 2012, 5:56:58 PM8/17/12
to prettyta...@googlegroups.com
I use prettytable and this problem appeared only in terminal (kubuntu 32bit konsole) and in ipython:

Traceback (most recent call last):
  File "calculations.py", line 94, in <module>
    My_PrettyTableGE.add_row(["σψ",SigmaPsi])
  File "/usr/lib/python2.7/dist-packages/prettytable.py", line 222, in add_row
    if len(unicode(row[i])) > self.widths[i]:
UnicodeDecodeError: 'ascii' codec can't decode byte 0xcf in position 0: ordinal not in range(128)

calculations.py is the python script i run to get the error. In kubuntu 64bit the script runs without any kind of problem in Konsole or any other program/interpreter. The weird thing is that in the same computer (the 32bit) using spyder the script runs without error. Konsole's profile is set to utf-8. Any ideas? I would also like to thank the developers, prettytable has saved me long hours of formatting output.cheers :)

Luke Maurits

unread,
Aug 20, 2012, 12:08:33 AM8/20/12
to prettyta...@googlegroups.com
Hi Cosmos,

I'm glad that PrettyTable has helped you save a lot of time wasted on
boring manual formatting. :)

Thanks for reporting the problem you were having. By the looks of the
traceback you posted, you're using PrettyTable 0.5? Line 222 is not
part of the add_row function in 0.6, which is how I can tell. I
suspect that upgrading to 0.6 will make this problem go away, as 0.6
has drastically better support for Unicode, which means it won't choke
on fancy characters like sigma and psi.

The downside is that there was a fairly drastic API change from 0.5 to
0.6, so it won't necessarily be a smooth upgrade. Actually getting
0.6 will be easy, you can just use easy-install or pip whatever to do
the upgrade. Try running your code again after that. It's possible
you'll get some syntax errors. Have a look at the examples in
the tutorial document at:

https://code.google.com/p/prettytable/wiki/Tutorial

and you should be able to figure out what changes to make. If you
can't solve anything, just post the code to this list and I'll help
you out.

If you upgrade to 0.6 and get rid of all the syntax errors and it is
still choking on Greek letters, then please post the new traceback and
I'll see if I can figure out what is going on.

Cheers,
Luke
Reply all
Reply to author
Forward
0 new messages