Skip to content

Commit f59fdb5

Browse files
author
Sam Spilsbury
committed
io/msgpack: Raise a more informative exception on file not found
1 parent ad2e98c commit f59fdb5

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

pandas/io/packers.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,8 @@ def read(fh):
184184
if exists:
185185
with open(path_or_buf, 'rb') as fh:
186186
return read(fh)
187+
else:
188+
return FileNotFoundError('{} not found'.format(path_or_buf))
187189

188190
if isinstance(path_or_buf, bytes):
189191
# treat as a binary-like

pandas/tests/io/test_packers.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -934,3 +934,7 @@ def test_msgpack_period_freq(self):
934934
s = Series(np.random.rand(5), index=date_range('20130101', periods=5))
935935
r = read_msgpack(s.to_msgpack())
936936
repr(r)
937+
938+
def test_msgpack_file_not_found(self):
939+
bad_path = '1/2/3/4/path/does/not/exist'
940+
pytest.raises(read_msgpack, FileNotFoundError, bad_path)

0 commit comments

Comments
 (0)