summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Hupp <adam@hupp.org>2020-08-13 14:56:54 -0700
committerAdam Hupp <adam@hupp.org>2020-08-13 14:56:54 -0700
commit1b6cede2550784251296496ad65ece8266e56250 (patch)
tree143a05796dbc104f519d2a306b582945ca4e60b8
parenta9ba472dc1e05385fc2cd9bb333c82caeefde36d (diff)
downloadpython-magic-1b6cede2550784251296496ad65ece8266e56250.tar.gz
Fallback to default behavior on setparam failure
Some versions of libmagic (unclear which) fail the setparam call in the Magic constructor. This this is just resolving a corner case to begin with, silently continue on if this happens.
-rw-r--r--magic.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/magic.py b/magic.py
index 7a1b1bd..cdf40c5 100644
--- a/magic.py
+++ b/magic.py
@@ -75,7 +75,12 @@ class Magic:
# or whether other internal limits should be increased, but given
# the lack of other reports I'll assume this is rare.
if _has_param:
- self.setparam(MAGIC_PARAM_NAME_MAX, 64)
+ try:
+ self.setparam(MAGIC_PARAM_NAME_MAX, 64)
+ except MagicException as e:
+ # some versions of libmagic fail this call,
+ # so rather than fail hard just use default behavior
+ pass
def from_buffer(self, buf):
"""