From 3d302619c57658d16e85a6203278710334d23c84 Mon Sep 17 00:00:00 2001 From: Thomas Krijnen Date: Sat, 20 Jun 2015 14:22:54 +0000 Subject: [PATCH] Check for numbers.Integral instead of int, to catch py2.7's long type as well --- src/ifcopenshell-python/ifcopenshell/__init__.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/ifcopenshell-python/ifcopenshell/__init__.py b/src/ifcopenshell-python/ifcopenshell/__init__.py index d007730aa1..4d9f8b4d34 100644 --- a/src/ifcopenshell-python/ifcopenshell/__init__.py +++ b/src/ifcopenshell-python/ifcopenshell/__init__.py @@ -19,6 +19,7 @@ import os import sys +import numbers import platform import functools import itertools @@ -66,7 +67,7 @@ class entity_instance(object): is_instance = lambda e: isinstance(e, entity_instance) return entity_instance.walk(is_instance, unwrap, v) def attribute_type(self, attr): - attr_idx = attr if isinstance(attr, int) else self.wrapped_data.get_argument_index(attr) + attr_idx = attr if isinstance(attr, numbers.Integral) else self.wrapped_data.get_argument_index(attr) return self.wrapped_data.get_argument_type(attr_idx) def attribute_name(self, attr_idx): return self.wrapped_data.get_argument_name(attr_idx) @@ -110,7 +111,7 @@ class file(object): if attr[0:6] == 'create': return functools.partial(self.create_entity,attr[6:]) else: return getattr(self.wrapped_data, attr) def __getitem__(self, key): - if isinstance(key, int): + if isinstance(key, numbers.Integral): return entity_instance(self.wrapped_data.by_id(key)) elif isinstance(key, str): return entity_instance(self.wrapped_data.by_guid(key))