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 @@ def __init__(self, mime=False, magic_file=None, mime_encoding=False, 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 @@ def __del__(self): # 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