From 5c7e7cab1a641ed9bfd25148b32cd04e714eca99 Mon Sep 17 00:00:00 2001 From: Thomas Krijnen Date: Wed, 2 Aug 2017 16:05:56 +0200 Subject: [PATCH] Raise IndexError --- src/ifcopenshell-python/ifcopenshell/entity_instance.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/ifcopenshell-python/ifcopenshell/entity_instance.py b/src/ifcopenshell-python/ifcopenshell/entity_instance.py index 658e01d80a..35e40598a8 100644 --- a/src/ifcopenshell-python/ifcopenshell/entity_instance.py +++ b/src/ifcopenshell-python/ifcopenshell/entity_instance.py @@ -80,6 +80,8 @@ class entity_instance(object): self[self.wrapped_data.get_argument_index(key)] = value def __getitem__(self, key): + if key < 0 or key >= len(self): + raise IndexError("Attribute index {} out of range for instance of type {}".format(key, self.is_a())) return entity_instance.wrap_value(self.wrapped_data.get_argument(key)) def __setitem__(self, idx, value):