Skip to content

Commit 2b8284c

Browse files
committed
print reading error in checkpoint.py
1 parent 2206d83 commit 2b8284c

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

python/magic/checkpoint.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,10 @@ def read(self, filename, endian='l'):
177177

178178
fmt = '{}i4'.format(prefix)
179179
self.version = np.fromfile(file, fmt, count=1)[0]
180+
if abs(self.version) > 100:
181+
print('File version is too large, reading error!')
182+
print('Either wrong endian or record markers')
183+
raise ValueError
180184
fmt = '{}f8'.format(prefix)
181185
self.time = np.fromfile(file, fmt, count=1)[0]
182186

0 commit comments

Comments
 (0)