[ttx] Close file before returning, to prevent ResourceWarnings in py3

This commit is contained in:
Miguel Sousa 2017-03-27 04:00:27 -07:00
parent 4fce7a0b7b
commit 076e2ba33a

View File

@ -285,12 +285,13 @@ def guessFileType(fileName):
f = open(fileName, "rb")
except IOError:
return None
header = f.read(256).lstrip(b'\xef\xbb\xbf')
f.close()
cr, tp = getMacCreatorAndType(fileName)
if tp in ("sfnt", "FFIL"):
return "TTF"
if ext == ".dfont":
return "TTF"
header = f.read(256).lstrip(b'\xef\xbb\xbf')
head = Tag(header[:4])
if head == "OTTO":
return "OTF"