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_
>>>'(NOT abc)')
{'hits': 2, 'results': [<SearchResult: (pk=u'1')>, <SearchResult
: (pk=u'2')>], 'spelling_suggestion': '', 'facets': {}}
>>>'(NOT a)')
Traceback (most recent call last):
  File "<ipython-input-17-fd1fb52d2a1e>", line 1, in <module>'(NOT a)')
  File "/home/tuxcanfly/Work/django-haystack/haystack/backends/", lin
e 26, in wrapper
    return func(obj, query_string, *args, **kwargs)
  File "/home/tuxcanfly/Work/django-haystack/haystack/backends/
", line 370, in search
    parsed_query = self.parser.parse(query_string)
  File "/home/tuxcanfly/Work/whoosh/src/whoosh/qparser/", line 364, in
    q = q.normalize()
  File "/home/tuxcanfly/Work/whoosh/src/whoosh/query/", line 116, in norm
    s = s.normalize()
  File "/home/tuxcanfly/Work/whoosh/src/whoosh/query/", line 128, in 
    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