From 7938787f80219ecbc959464086dcf65256e809c7 Mon Sep 17 00:00:00 2001 From: stefan Date: Tue, 24 Nov 2009 20:12:52 +0000 Subject: [PATCH] Fix Issue2550609. git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/roundup/trunk@4386 57a73879-2fb5-44c3-a270-3262357dd7e2 --- roundup/backends/indexer_rdbms.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/roundup/backends/indexer_rdbms.py b/roundup/backends/indexer_rdbms.py index 83d91ae..3155c02 100644 --- a/roundup/backends/indexer_rdbms.py +++ b/roundup/backends/indexer_rdbms.py @@ -64,10 +64,14 @@ class Indexer(IndexerBase): self.db.cursor.execute(sql, (id, )) # ok, find all the unique words in the text - text = unicode(text, "utf-8", "replace").upper() - wordlist = [w.encode("utf-8") - for w in re.findall(r'(?u)\b\w{%d,%d}\b' - % (self.minlength, self.maxlength), text)] + def tryencode(str): + if not isinstance(str, unicode): + str = str.encode("utf-8", "replace") + return str + text = tryencode(text).upper() + wordlist = [tryencode(w) + for w in re.findall(r'(?u)\b\w{%d,%d}\b' + % (self.minlength, self.maxlength), text)] words = set() for word in wordlist: if self.is_stopword(word): continue -- 2.30.2