1. Matt Chaput
  2. whoosh
Issue #313 resolved

AttributeError: 'NoneType' object has no attribute 'normalize' - Edge case in NOT parser

Anonymous created an issue

Passing a query containing a single char after NOT crashes whoosh. Here's a sample traceback:

>>> from django.conf import settings
>>> from haystack.backends import whoosh_backend
>>> backend = whoosh_backend.WhooshSearchBackend('default', **settings.HAYSTACK_
CONNECTIONS['default'])
>>> backend.search(u'(NOT abc)')
{'hits': 2, 'results': [<SearchResult: regular_app.dog (pk=u'1')>, <SearchResult
: regular_app.dog (pk=u'2')>], 'spelling_suggestion': '', 'facets': {}}
>>> backend.search(u'(NOT a)')
Traceback (most recent call last):
  File "<ipython-input-17-fd1fb52d2a1e>", line 1, in <module>
    backend.search(u'(NOT a)')
  File "/home/tuxcanfly/Work/django-haystack/haystack/backends/__init__.py", lin
e 26, in wrapper
    return func(obj, query_string, *args, **kwargs)
  File "/home/tuxcanfly/Work/django-haystack/haystack/backends/whoosh_backend.py
", line 370, in search
    parsed_query = self.parser.parse(query_string)
  File "/home/tuxcanfly/Work/whoosh/src/whoosh/qparser/default.py", line 364, in
 parse
    q = q.normalize()
  File "/home/tuxcanfly/Work/whoosh/src/whoosh/query/nary.py", line 116, in norm
alize
    s = s.normalize()
  File "/home/tuxcanfly/Work/whoosh/src/whoosh/query/wrappers.py", line 128, in 
normalize
    q = self.query.normalize()
AttributeError: 'NoneType' object has no attribute 'normalize'

The problem appears to be in the NOT query parser, though I couldn't find the exact source of the behaviour.

Comments (1)

  1. Log in to comment