summaryrefslogtreecommitdiff
path: root/magic.py
diff options
context:
space:
mode:
authorAdam Hupp <adam@hupp.org>2020-11-06 10:39:10 -0800
committerAdam Hupp <adam@hupp.org>2020-11-06 10:39:10 -0800
commit77b8cbea6ceffecb4cbc471d1e8fa22843389439 (patch)
tree98ed14f0598fd626c1948c9b3c7214cddf15917b /magic.py
parent2a755bed47e654d353f002eb2ee19820dc21d53a (diff)
downloadpython-magic-77b8cbea6ceffecb4cbc471d1e8fa22843389439.tar.gz
Handle libmagic versions that don't support MAGIC_EXTENSION
extension support was added to libmagic in 2015 in 9190a18d09f25fb0ca6abe1fcbdba780f5077e45. This change: - updates the test to handle various verions that return garbage / empty string.s - throws an exception in magic.Magic if extension support is requested and we know its not supported.
Diffstat (limited to 'magic.py')
-rw-r--r--magic.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/magic.py b/magic.py
index 773e4ae..aab7987 100644
--- a/magic.py
+++ b/magic.py
@@ -70,6 +70,10 @@ class Magic:
magic_load(self.cookie, magic_file)
+ # MAGIC_EXTENSION was added in 523 or 524, so bail if
+ # it doesn't appear to be available
+ if extension and (not _has_version or version() < 524):
+ raise NotImplementedError('MAGIC_EXTENSION is not supported in this version of libmagic')
# For https://github.com/ahupp/python-magic/issues/190
# libmagic has fixed internal limits that some files exceed, causing