diff options
| author | Andrew Lamoureux <andrew@vector35.com> | 2019-03-23 01:15:14 -0400 |
|---|---|---|
| committer | Andrew Lamoureux <andrew@vector35.com> | 2019-03-23 01:15:14 -0400 |
| commit | 334c0e966eeb67cc88975cc51c3b7e17f7d1b1ee (patch) | |
| tree | fbee805aa70f1b85f4513f488df5e0683458da98 /python/examples/kaitai/kaitaistruct.py | |
| parent | af001b025b5aad5b205cb97977f3951fe6ef2a71 (diff) | |
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
Diffstat (limited to 'python/examples/kaitai/kaitaistruct.py')
| -rw-r--r-- | python/examples/kaitai/kaitaistruct.py | 4 |
1 files changed, 2 insertions, 2 deletions
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 |
