[ttLib] call XMLWriter.close() only if 'fileOrPath' is a path, not when it's a file

This allows to call `TTFont.saveXML` with an already open file/stream (e.g. sys.stdout or a StringIO) without it being abruptly closed at the end.

We do the same elsewhere when we reiceive file handles instead of path names, so we might do it here too.
This commit is contained in:
Cosimo Lupo 2016-02-02 18:25:43 +00:00
parent faeba0c0c0
commit 84d6f076a3

View File

@ -308,7 +308,9 @@ class TTFont(object):
progress.set((i + 1))
writer.endtag("ttFont")
writer.newline()
writer.close()
# close if 'fileOrPath' is a path; leave it open if it's a file
if not hasattr(fileOrPath, "write"):
writer.close()
def _tableToXML(self, writer, tag, progress, quiet=None):
if quiet is not None: