Skip to content

Commit e6d7ee0

Browse files
authored
Merge pull request #244 from jspricke/fix_del_cookie
Check for cookie attribute before trying to delete it
2 parents 53aa709 + 12d0ea0 commit e6d7ee0

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

magic/__init__.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,6 @@ def __init__(self, mime=False, magic_file=None, mime_encoding=False,
5353
raw - Do not try to decode "non-printable" chars.
5454
extension - Print a slash-separated list of valid extensions for the file type found.
5555
"""
56-
57-
self.cookie = None
5856
self.flags = MAGIC_NONE
5957
if mime:
6058
self.flags |= MAGIC_MIME_TYPE
@@ -152,7 +150,7 @@ def __del__(self):
152150
# incorrect fix for a threading problem, however I'm leaving
153151
# it in because it's harmless and I'm slightly afraid to
154152
# remove it.
155-
if self.cookie and magic_close:
153+
if hasattr(self, 'cookie') and self.cookie and magic_close:
156154
magic_close(self.cookie)
157155
self.cookie = None
158156

0 commit comments

Comments
 (0)