From 1da9217a1820f3144d624e2c76e48db0599588d1 Mon Sep 17 00:00:00 2001 From: Griatch Date: Sat, 20 Aug 2016 11:00:33 +0200 Subject: [PATCH] Return no match if using obj.search() with an empty list of candidates. This accounts for candidate lists that are created dynamically, for example limiting them to the inventory (which may be empy). Resolves #1016. --- evennia/contrib/rpsystem.py | 2 +- evennia/objects/manager.py | 5 ++++- evennia/objects/objects.py | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/evennia/contrib/rpsystem.py b/evennia/contrib/rpsystem.py index 5e917f6c80..6a6874536a 100644 --- a/evennia/contrib/rpsystem.py +++ b/evennia/contrib/rpsystem.py @@ -1155,7 +1155,7 @@ class ContribRPObject(DefaultObject): # only allow exact matching if searching the entire database # or unique #dbrefs exact = True - elif not candidates: + elif candidates is None: # no custom candidates given - get them automatically if location: # location(s) were given diff --git a/evennia/objects/manager.py b/evennia/objects/manager.py index d3301e536d..656d699b3f 100644 --- a/evennia/objects/manager.py +++ b/evennia/objects/manager.py @@ -357,7 +357,10 @@ class ObjectDBManager(TypedObjectManager): typeclasses[i] = u"%s" % typeclass typeclass = typeclasses - if candidates: + if candidates is not None: + if not candidates: + # candidates is the empty list. This should mean no matches can ever be acquired. + return [] # Convenience check to make sure candidates are really dbobjs candidates = [cand for cand in make_iter(candidates) if cand] if typeclass: diff --git a/evennia/objects/objects.py b/evennia/objects/objects.py index eb96d6dfe3..97145a0ade 100644 --- a/evennia/objects/objects.py +++ b/evennia/objects/objects.py @@ -361,7 +361,7 @@ class DefaultObject(with_metaclass(TypeclassBase, ObjectDB)): # only allow exact matching if searching the entire database # or unique #dbrefs exact = True - elif not candidates: + elif candidates is None: # no custom candidates given - get them automatically if location: # location(s) were given