From 63f5253ec7461503aa2986cb6813b9597a07a51f Mon Sep 17 00:00:00 2001 From: Cosimo Lupo Date: Wed, 18 Jan 2017 12:06:46 +0000 Subject: [PATCH] [ttLib] don't close stdout in TTFont.saveXML() otherwise when dumping multiple TTX to standard output it raises: ValueError: I/O operation on closed file --- Lib/fontTools/ttLib/__init__.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Lib/fontTools/ttLib/__init__.py b/Lib/fontTools/ttLib/__init__.py index 5e31a6b47..b45b76539 100644 --- a/Lib/fontTools/ttLib/__init__.py +++ b/Lib/fontTools/ttLib/__init__.py @@ -314,8 +314,9 @@ class TTFont(object): progress.set((i + 1)) writer.endtag("ttFont") writer.newline() - # close if 'fileOrPath' is a path; leave it open if it's a file - if not hasattr(fileOrPath, "write"): + # close if 'fileOrPath' is a path; leave it open if it's a file. + # The special string "-" means standard output so leave that open too + if not hasattr(fileOrPath, "write") and fileOrPath != "-": writer.close() def _tableToXML(self, writer, tag, progress, quiet=None):