# HG changeset patch # User Mads Kiilerich # Date 2019-11-20 12:55:14 # Node ID 552f6738ace24fb56ffcf70cf460581a958049e8 # Parent e2b9731cb2fb1e692709ef93ccbc6d26cd38f04c search: avoid crash when making (odd) search for '*' Crashed in whoosh ListMatcher.supports() on def supports(self, astype): return self._format.supports(astype) with AttributeError: 'NoneType' object has no attribute 'supports' on for example http://localhost:5000/_admin/search?q=*&type=content . There doesn't seem to be a good way to detect if _format has been provided. diff --git a/kallithea/lib/indexers/__init__.py b/kallithea/lib/indexers/__init__.py --- a/kallithea/lib/indexers/__init__.py +++ b/kallithea/lib/indexers/__init__.py @@ -212,7 +212,11 @@ class WhooshResultWrapper(object): close occurrences twice. """ memory = [(0, 0)] - if self.matcher.supports('positions'): + try: + supports_positions = self.matcher.supports('positions') + except AttributeError: # 'NoneType' object has no attribute 'supports' (because matcher never get a format) + supports_positions = False + if supports_positions: for span in self.matcher.spans(): start = span.startchar or 0 end = span.endchar or 0