UnicodeDecodeError with spi and grep

You think you have found a bug? Let us know about it.
Post Reply
dracotilla
Posts: 1
Joined: 11. May 2014, 12:31

UnicodeDecodeError with spi and grep

Post by dracotilla »

Hello! New to salix forum and first post

I get a 'UnicodeDecodeError' while filtering spi output.

Example:

spi python | grep -i kde

lists pykde4 (the package i was looking for) and after that

Traceback (most recent call last):
File "/usr/bin/spi", line 436, in <module>
main(sys.argv[1:])
File "/usr/bin/spi", line 94, in main
search(args)
File "/usr/bin/spi", line 205, in search
print pkgname+' ['+pkginst+']:', pkgdesc
File "/usr/lib64/python2.7/codecs.py", line 351, in write
data , consumed = self.encode(object, self.errors)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 52: ordinal not in range(128)

Searching 'spi x | grep <anything>' shows same error, just changes byte and position in last line.

Filtering find, locate or cat (for example) with grep don't show error, as well as spi <anything>, and spi works ok apart from the error, as I could install pykde4 after that.

System is Salix 14.1 Kde beta1 64 bits, fresh install on empty / and /home partitions. Only Abiword and Gnumeric installed before that.

Any idea? Could it be my fault?
User avatar
gapan
Salix Wizard
Posts: 6241
Joined: 6. Jun 2009, 17:40

Re: UnicodeDecodeError with spi and grep

Post by gapan »

Not your fault. This is actually a bug/problem with python. When outputting directly to the terminal it knows what encoding to use, but when piping the output, it doesn't. A workaround is to set:

Code: Select all

export PYTHONIOENCODING=utf-8
and then run the command. You can add that to your ~/.bashrc if you like.

I'll try to find if there is another workaround that I can use directly in spi...
Image
Image
User avatar
gapan
Salix Wizard
Posts: 6241
Joined: 6. Jun 2009, 17:40

Re: UnicodeDecodeError with spi and grep

Post by gapan »

I have uploaded spi 0.4 to the repos. It fixes this problem without having to export that variable anymore.
Image
Image
Post Reply