diff options
author | Adam Hupp <adam@hupp.org> | 2020-08-13 14:56:54 -0700 |
---|---|---|
committer | Adam Hupp <adam@hupp.org> | 2020-08-13 14:56:54 -0700 |
commit | 1b6cede2550784251296496ad65ece8266e56250 (patch) | |
tree | 143a05796dbc104f519d2a306b582945ca4e60b8 | |
parent | a9ba472dc1e05385fc2cd9bb333c82caeefde36d (diff) | |
download | python-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.py | 7 |
1 files changed, 6 insertions, 1 deletions
@@ -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): """ |