From 192fd8ec2e851a6b43b17a2b9bc40cfd700032ea Mon Sep 17 00:00:00 2001 From: Anthony Weems Date: Mon, 21 Dec 2015 12:28:47 -0600 Subject: [PATCH] Check that attr exists before access --- pyvex/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pyvex/__init__.py b/pyvex/__init__.py index ac5c2996..9ea3b187 100644 --- a/pyvex/__init__.py +++ b/pyvex/__init__.py @@ -39,8 +39,8 @@ pvc = ffi.dlopen(pyvex_path) #pylint:disable=undefined-loop-variable pvc.vex_init() dir(pvc) # lookup all the definitions (wtf) -enums_to_ints = { _:getattr(pvc,_) for _ in dir(pvc) if isinstance(getattr(pvc,_), int) } -ints_to_enums = { getattr(pvc,_):_ for _ in dir(pvc) if isinstance(getattr(pvc,_), int) } +enums_to_ints = { _:getattr(pvc,_) for _ in dir(pvc) if hasattr(pvc,_) and isinstance(getattr(pvc,_), int) } +ints_to_enums = { getattr(pvc,_):_ for _ in dir(pvc) if hasattr(pvc,_) and isinstance(getattr(pvc,_), int) } enum_IROp_fromstr = { _:enums_to_ints[_] for _ in enums_to_ints if _.startswith('Iop_') } type_sizes = { 'Ity_INVALID': None,