Hi all,
I was adding passing python unicode objects to solr.add and got these sort of errors:
...
File "/Users/jamesbrady/Documents/workspace/YelServer/yel/ solr.py", line 152, in add
    self.__add(lst,fields)
File "/Users/jamesbrady/Documents/workspace/YelServer/yel/ solr.py", line 146, in __add
    lst.append(self.escapeVal(str(v)))
UnicodeEncodeError: 'ascii' codec can't encode characters in position 30-31: ordinal not in range(128)

Here's a diff which properly checks the object type before calling str ():
142a143,146
>       if not isinstance(f, basestring):
>         f = str(f)
>       if not isinstance(v, basestring):
>         v = str(v)
144c148
<       lst.append(self.escapeKey(str(f)))
---
>       lst.append(self.escapeKey(f))
146c150
<       lst.append(self.escapeVal(str(v)))
---
>       lst.append(self.escapeVal(v))

Keep up the good work - loving Solr so far!
James

Reply via email to