Skip to content

Commit 7e4c486

Browse files
authored
Merge pull request #259 from martindurant/mapping_error
Only catch FileNotFound in mapping get
2 parents 4a064c3 + 9f52132 commit 7e4c486

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

fsspec/implementations/memory.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class MemoryFileSystem(AbstractFileSystem):
1515
protocol = "memory"
1616
root_marker = ""
1717

18-
def ls(self, path, detail=False):
18+
def ls(self, path, detail=False, **kwargs):
1919
if path in self.store:
2020
# there is a key with this exact name, but could also be directory
2121
out = [
@@ -127,7 +127,10 @@ def copy(self, path1, path2, **kwargs):
127127
self.store[path2] = MemoryFile(self, path2, self.store[path1].getbuffer())
128128

129129
def cat(self, path):
130-
return self.store[path].getvalue()
130+
try:
131+
return self.store[path].getvalue()
132+
except KeyError:
133+
raise FileNotFoundError(path)
131134

132135
def _rm(self, path):
133136
del self.store[path]

fsspec/mapping.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,10 @@ def _str_to_key(self, s):
7171

7272
def __getitem__(self, key, default=None):
7373
"""Retrieve data"""
74-
key = self._key_to_str(key)
74+
k = self._key_to_str(key)
7575
try:
76-
result = self.fs.cat(key)
77-
except: # noqa: E722
76+
result = self.fs.cat(k)
77+
except FileNotFoundError:
7878
if default is not None:
7979
return default
8080
raise KeyError(key)

tox.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ conda_deps=
2121
pytest
2222
pytest-cov
2323
fusepy==3.0.1
24+
msgpack-python<1.0.0
2425
deps=
2526
hadoop-test-cluster==0.1.0
2627

0 commit comments

Comments
 (0)