summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--magic/__init__.py4
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