Possible bug dealing with Unicode...

42 views
Skip to first unread message

Michael Lissner

unread,
Jan 16, 2012, 7:19:16 PM1/16/12
to Python Sunburnt
I hate Unicode too much to get beyond simply hacking my way around
this, but I encountered an error when adding certain documents to the
index.

The error was occurring in schema.py, in the following function:

class SolrUnicodeField(SolrField):
def from_user_data(self, value):
if isinstance(value, SolrString):
return value
elif isinstance(value, unicode) or isinstance(value, long):
return WildcardString(unicode(value))
else:
return WildcardString(unicode(value, encoding='utf-8'))

There was one problem, that required two fixes:
1. The encoding wasn't provided, and on my system that was defaulting
to ascii, which occasionally crashed.
2. Once the encoding is in place, things get wonky for other types of
variables, so I added the elif statement as well.

My solution is certainly not robust (and it's a hack), but I figured
I'd put it up here to see if this was a problem unique to me, or if
this was something others would run into.

And also to see what the better solution to this is, if anybody knows
offhand.

Mike
Reply all
Reply to author
Forward
0 new messages