From faf15192c0b77b6630912d7ff5c575c755be522c Mon Sep 17 00:00:00 2001 From: maho Date: Mon, 16 Oct 2017 11:53:48 +0200 Subject: [PATCH 1/3] - key error instead of meaningless index-error --- modules/core/kivent_core/managers/system_manager.pyx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/modules/core/kivent_core/managers/system_manager.pyx b/modules/core/kivent_core/managers/system_manager.pyx index f177dedc..48da956b 100644 --- a/modules/core/kivent_core/managers/system_manager.pyx +++ b/modules/core/kivent_core/managers/system_manager.pyx @@ -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 @@ -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): From 2d02595dfbd93dd4192ebc607cc995b5fc60979c Mon Sep 17 00:00:00 2001 From: maho Date: Mon, 16 Oct 2017 12:09:18 +0200 Subject: [PATCH 2/3] - and another place for key error --- modules/core/kivent_core/systems/staticmemgamesystem.pyx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/modules/core/kivent_core/systems/staticmemgamesystem.pyx b/modules/core/kivent_core/systems/staticmemgamesystem.pyx index f7f8f590..d17e18ef 100644 --- a/modules/core/kivent_core/systems/staticmemgamesystem.pyx +++ b/modules/core/kivent_core/systems/staticmemgamesystem.pyx @@ -601,6 +601,8 @@ 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) + if system_index == (-1): + raise KeyError(system_name) component_index = entity[system_index+1] system = systems[system_index] memory_zone = system.imz_components.memory_zone From 41acd98433d7732baef01f1c00b2e5c308c6a4ac Mon Sep 17 00:00:00 2001 From: maho Date: Mon, 16 Oct 2017 12:18:29 +0200 Subject: [PATCH 3/3] - I'm not sure about this one --- .../core/kivent_core/systems/staticmemgamesystem.pyx | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/modules/core/kivent_core/systems/staticmemgamesystem.pyx b/modules/core/kivent_core/systems/staticmemgamesystem.pyx index d17e18ef..7ca2055a 100644 --- a/modules/core/kivent_core/systems/staticmemgamesystem.pyx +++ b/modules/core/kivent_core/systems/staticmemgamesystem.pyx @@ -603,8 +603,11 @@ cdef class ComponentPointerAggregator: system_index = system_manager.get_system_index(system_name) if system_index == (-1): raise KeyError(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) + 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