# HG changeset patch # User KarstenBock@gmx.net # Date 1314960883 -7200 # Node ID 3bacef35b2522fff7f0d8adc68cbfd67e37cb6ca # Parent 0443ab9533cef46819f84fcd0f8eec215c55bfb4 get_free_slot no raises an exception instead of appending a slot to the container. diff -r 0443ab9533ce -r 3bacef35b252 src/parpg/components/container.py --- a/src/parpg/components/container.py Fri Sep 02 12:29:55 2011 +0200 +++ b/src/parpg/components/container.py Fri Sep 02 12:54:43 2011 +0200 @@ -32,7 +32,13 @@ def __str__(self): return "Item would exceed the bulk limit of the container." - + +class NoFreeSlotError(Exception): + """Error that gets raised when the container has no free slots.""" + + def __str__(self): + return "Container can't hold any more items." + def get_free_slot(container): """Returns the first slot of the container that is not occupied.""" index = 0 @@ -40,8 +46,7 @@ if not child: return index index += 1 - container.children.append(None) - return index + raise NoFreeSlotError def get_total_bulk(container): """Returns the bulk of all items in the container."""