Fredrik Lundh fredrik at pythonware.com
Wed Nov 30 19:14:36 CET 2005

"ash" wrote:

> one of the modules in my programs stopped wroking after i upgraded from
> python 2.3 to 2.4. I also changed my wxPython to unicode supported one
> during the process.
>  what the module essentially does is search for a stirng pattern form a
> list of strings.
> this is the function:
> def srchqu(self):
>     for i in range(1,len(qu)):#qu is the list of strings
>         if qu[i][0].lower().find(self.query)==-1:
>             pass
>         else:
>             #do some stuff here
> I get this error message on calling the function:
> Traceback (most recent call last):
>   File "E:\mdi\search.py", line 86, in OnSrchButton
>     self.srchqu()
>   File "E:\mdi\search.py", line 97, in srchqu
>     if qu[i][0].lower().find(self.query)==-1:
> UnicodeDecodeError: 'ascii' codec can't decode byte 0x92 in position
> 66: ordinal not in range(128)
> what is the problem and the solution? thanks in advance for any help.

one of qu[i][0] or self.query is a unicode string, and the other is an 8-bit
string that contains something that's not ASCII.

to make the code do what you do, make sure to decode the 8-bit strings
into Unicode strings.


More information about the Python-list mailing list