diff options
author | Adam Hupp <adam@hupp.org> | 2021-05-17 08:52:47 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-17 08:52:47 -0700 |
commit | e6d7ee03c6935c54a83fa450607e57db04ec2bbe (patch) | |
tree | 4d40c6b1e509bc8cf29e179ce8473ee74589f580 | |
parent | 53aa709affef18cb2d1c5930f780dabfc5e4330c (diff) | |
parent | 12d0ea062d92a15baee69c4be0e4ae00fcdee416 (diff) | |
download | python-magic-e6d7ee03c6935c54a83fa450607e57db04ec2bbe.tar.gz |
Merge pull request #244 from jspricke/fix_del_cookie
Check for cookie attribute before trying to delete it
-rw-r--r-- | magic/__init__.py | 4 |
1 files changed, 1 insertions, 3 deletions
diff --git a/magic/__init__.py b/magic/__init__.py index f10a38a..363e88f 100644 --- a/magic/__init__.py +++ b/magic/__init__.py @@ -53,8 +53,6 @@ class Magic: raw - Do not try to decode "non-printable" chars. extension - Print a slash-separated list of valid extensions for the file type found. """ - - self.cookie = None self.flags = MAGIC_NONE if mime: self.flags |= MAGIC_MIME_TYPE @@ -152,7 +150,7 @@ class Magic: # incorrect fix for a threading problem, however I'm leaving # it in because it's harmless and I'm slightly afraid to # remove it. - if self.cookie and magic_close: + if hasattr(self, 'cookie') and self.cookie and magic_close: magic_close(self.cookie) self.cookie = None |