Commit 1d1e8810 authored by W. Trevor King's avatar W. Trevor King
Browse files

Add 'not enough data...' errors to packed.load().

parent a2151cb1
......@@ -55,6 +55,10 @@ def load(filename, strict=True, ignore_unknown=True):
b = buffer(
if not b:
if len(b) < PackedFileRecordHeader.size:
raise ValueError(
('not enough data for the next record header ({} < {})'
).format(len(b), PackedFileRecordHeader.size))
_LOG.debug('reading a new packed experiment file record')
header = PackedFileRecordHeader.unpack_from(b)
if header['version'] and not byte_order:
......@@ -70,6 +74,10 @@ def load(filename, strict=True, ignore_unknown=True):
'reordered version: {}'.format(header['version']))
data = buffer(['numDataBytes']))
if len(data) < header['numDataBytes']:
raise ValueError(
('not enough data for the next record ({} < {})'
).format(len(b), header['numDataBytes']))
record_type = _RECORD_TYPE.get(
header['recordType'] & PACKEDRECTYPE_MASK, _UnknownRecord)
_LOG.debug('the new record has type {} ({}).'.format(
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment