Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

- key error instead of meaningless index-error #262

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion modules/core/kivent_core/managers/system_manager.pyx
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# cython: embedsignature=True
from kivy.logger import Logger

from kivent_core.managers.game_manager cimport GameManager
'''
GameWorld uses these system management classes to keep track of the GameSystems
Expand Down Expand Up @@ -160,7 +162,10 @@ cdef class SystemManager(GameManager):
'''

def __getitem__(self, str name):
return self.systems[self.get_system_index(name)]
try:
return self.systems[self.get_system_index(name)]
except IndexError:
raise KeyError(name)

property update_order:
def __get__(self):
Expand Down
13 changes: 9 additions & 4 deletions modules/core/kivent_core/systems/staticmemgamesystem.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -601,8 +601,13 @@ cdef class ComponentPointerAggregator:
for i, system_name in enumerate(self.system_names):
pointer_loc = adjusted_index + i
system_index = system_manager.get_system_index(system_name)
component_index = entity[system_index+1]
system = systems[system_index]
memory_zone = system.imz_components.memory_zone
data[pointer_loc] = memory_zone.get_pointer(component_index)
if system_index == <unsigned int>(-1):
raise KeyError(system_name)
try:
component_index = entity[system_index+1]
system = systems[system_index]
memory_zone = system.imz_components.memory_zone
data[pointer_loc] = memory_zone.get_pointer(component_index)
except IndexError, e:
raise KeyError("missing key=%s raised %s"%(system_name, e))
return block_index