Skip to content

Commit

Permalink
try catching TypeError instead
Browse files Browse the repository at this point in the history
  • Loading branch information
vangheem committed Aug 20, 2015
1 parent 9c0933d commit 43e8fb8
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/zope/index/field/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,19 +55,25 @@ def index_doc(self, docid, value):
"""See interface IInjection"""
rev_index = self._rev_index
if docid in rev_index:
if value is not None and docid in self._fwd_index.get(value, ()):
# no need to index the doc, its already up to date
try:
if docid in self._fwd_index.get(value, ()):
# no need to index the doc, its already up to date
return
except TypeError:
return
# unindex doc if present
self.unindex_doc(docid)

if value is not None:
try:
# Insert into forward index.
set = self._fwd_index.get(value)
if set is None:
set = self.family.IF.TreeSet()
self._fwd_index[value] = set
set.insert(docid)
except TypeError:
# TypeError is caused by improper keys on the latest version of BTree
pass

# increment doc count
self._num_docs.change(1)
Expand Down

0 comments on commit 43e8fb8

Please sign in to comment.