From 334c0e966eeb67cc88975cc51c3b7e17f7d1b1ee Mon Sep 17 00:00:00 2001 From: Andrew Lamoureux Date: Sat, 23 Mar 2019 01:15:14 -0400 Subject: kaitai: python3-compatible forgiveness for struct properties hasattr() on python2 has built in exception handler that would return False when computation of a property screwed up - that doesnt exist in python3 --- python/examples/kaitai/kaitaistruct.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'python/examples/kaitai/kaitaistruct.py') diff --git a/python/examples/kaitai/kaitaistruct.py b/python/examples/kaitai/kaitaistruct.py index 4d588b9f..1bcc31f1 100644 --- a/python/examples/kaitai/kaitaistruct.py +++ b/python/examples/kaitai/kaitaistruct.py @@ -33,7 +33,7 @@ class KaitaiStruct(object): f = open(filename, 'rb') try: return cls(KaitaiStream(f)) - except Exception: + except Exception as e: # close file descriptor, then reraise the exception f.close() raise @@ -375,5 +375,5 @@ class KaitaiStream(object): """ try: return enum_obj(value) - except ValueError: + except ValueError as e: return value -- cgit v1.3.1