Crash fix: lookup with empty prefixes.

This commit is contained in:
Eevee 2010-09-12 21:08:50 -07:00
parent 27364e1fbc
commit cf72e1db36
2 changed files with 10 additions and 1 deletions

View file

@ -296,7 +296,11 @@ class PokedexLookup(object):
name = name.strip() name = name.strip()
prefixes = prefix_chunk.split(',') prefixes = prefix_chunk.split(',')
user_valid_types = [_.strip() for _ in prefixes] user_valid_types = []
for prefix in prefixes:
prefix = prefix.strip()
if prefix:
user_valid_types.append(prefix)
# Merge the valid types together. Only types that appear in BOTH lists # Merge the valid types together. Only types that appear in BOTH lists
# may be used. # may be used.

View file

@ -146,3 +146,8 @@ def test_random_lookup():
assert_equal(len(results), 1, u'Constrained random returns one result') assert_equal(len(results), 1, u'Constrained random returns one result')
assert_equal(results[0].object.__tablename__, table_name, assert_equal(results[0].object.__tablename__, table_name,
u'Constrained random returns result from the right table') u'Constrained random returns result from the right table')
def test_crash_empty_prefix():
"""Searching for ':foo' used to crash, augh!"""
results = lookup.lookup(u'Eevee')
assert_equal(results[0].object.name, u'Eevee', u'Empty prefix dun crash')