From aa2443af6e6de74edff19757ba1c827b69f7640f Mon Sep 17 00:00:00 2001 From: Max Sperlich Date: Sun, 8 Dec 2013 20:57:23 -0500 Subject: TST: Adds test case for Issue 4093 --- numpy/lib/format.py | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'numpy/lib/format.py') diff --git a/numpy/lib/format.py b/numpy/lib/format.py index 8eb5059a0..2dd1a68af 100644 --- a/numpy/lib/format.py +++ b/numpy/lib/format.py @@ -481,6 +481,10 @@ def read_array(fp): while i < count: read_count = min(max_read_count, count - i) data = extra_data + fp.read(int(read_count * dtype.itemsize)) + if len(data) == len(extra_data): + #Unable to read sufficient data from fp + msg = "EOF: expected %d entries, got %d entries" % (count, i) + raise ValueError(msg) actual_count = len(data) // dtype.itemsize extra_data = data[actual_count*dtype.itemsize:] array[i:i+actual_count] = numpy.frombuffer(data, dtype=dtype, -- cgit v1.2.1