diff options
author | Ofer Koren <koreno@gmail.com> | 2020-08-14 00:34:52 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-14 00:34:52 +0300 |
commit | 16972c2c6fda3573860f5f8b0f2c03b757e71d3c (patch) | |
tree | 0c9aae9a87b5985c2b43533612551b517f79fa91 | |
parent | 1a9f90ac5c6b6eb93495595e1af4407943f3e278 (diff) | |
download | python-magic-16972c2c6fda3573860f5f8b0f2c03b757e71d3c.tar.gz |
Fix bug in Magic when destructor called too early
Potentially `magic_open` may fail, and when python attempts to gc the Magic instance it fails with:
```
Exception ignored in: <function Magic.__del__ at 0x7f595ba06430>
Traceback (most recent call last):
File "/usr/local/lib/python3.8/site-packages/magic.py", line 129, in __del__
if self.cookie and magic_close:
AttributeError: 'Magic' object has no attribute 'cookie'
```
-rw-r--r-- | magic.py | 2 |
1 files changed, 2 insertions, 0 deletions
@@ -48,6 +48,8 @@ class Magic: uncompress - Try to look inside compressed files. raw - Do not try to decode "non-printable" chars. """ + + self.cookie = None self.flags = MAGIC_NONE if mime: self.flags |= MAGIC_MIME_TYPE |