diff options
| author | Christos Zoulas <christos@zoulas.com> | 2022-09-01 10:27:21 +0000 |
|---|---|---|
| committer | Christos Zoulas <christos@zoulas.com> | 2022-09-01 10:27:21 +0000 |
| commit | 1770d23e069fc32cea058fe15bc9c1a8304e3aa1 (patch) | |
| tree | 5b7eefcea525b238af4825d499a21790fd460a8d /python/magic.py | |
| parent | 904234054c5dd798e5f6f21c0c3cccf6071dc5b8 (diff) | |
| download | file-git-1770d23e069fc32cea058fe15bc9c1a8304e3aa1.tar.gz | |
fix python tests, better cleanup
Diffstat (limited to 'python/magic.py')
| -rw-r--r-- | python/magic.py | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/python/magic.py b/python/magic.py index 8b48f757..4300ee07 100644 --- a/python/magic.py +++ b/python/magic.py @@ -288,16 +288,26 @@ class MagicDetect(object): if self.mime_magic is None: raise error if self.mime_magic.load() == -1: + self.mime_magic.close() + self.mime_magic = None raise error self.none_magic = open(MAGIC_NONE) if self.none_magic is None: + self.mime_magic.close() + self.mime_magic = None raise error if self.none_magic.load() == -1: + self.none_magic.close() + self.none_magic = None + self.mime_magic.close() + self.mime_magic = None raise error def __del__(self): - self.mime_magic.close() - self.none_magic.close() + if self.mime_magic is not None: + self.mime_magic.close() + if self.none_magic is not None: + self.none_magic.close() threadlocal = threading.local() |
