Skip to content

Commit 0a2fda3

Browse files
committed
handle unknown platforms gracefully in loader.py
1 parent cf21065 commit 0a2fda3

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

magic/loader.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,9 @@ def _lib_candidates():
4949
"darwin": _lib_candidates_macos,
5050
"linux": _lib_candidates_linux,
5151
"win32": _lib_candidates_windows,
52-
}[sys.platform]
52+
}.get(sys.platform)
53+
if func is None:
54+
raise ImportError("python-magic: Unsupported platform: " + sys.platform)
5355
# When we drop legacy Python, we can just `yield from func()`
5456
for path in func():
5557
yield path
@@ -65,4 +67,4 @@ def load_lib():
6567
pass
6668

6769
# It is better to raise an ImportError since we are importing magic module
68-
raise ImportError("failed to find libmagic. Check your installation")
70+
raise ImportError("python-magic: failed to find libmagic. Check your installation")

0 commit comments

Comments
 (0)