From ca1b3967b00738deed8b0b4d462df4c79f7f20ba Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 17 Oct 2019 19:51:32 +0530 Subject: [PATCH] Fix #1848515 [Faile to compile translation file on 4.1.0](https://bugs.launchpad.net/calibre/+bug/1848515) --- src/calibre/translations/msgfmt.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/calibre/translations/msgfmt.py b/src/calibre/translations/msgfmt.py index 3c737b0c20..089f94c115 100644 --- a/src/calibre/translations/msgfmt.py +++ b/src/calibre/translations/msgfmt.py @@ -222,10 +222,12 @@ def make(filename, outfile): # Compute output output = generate() - try: - with open(outfile,"wb") as f: - f.write(output) + if hasattr(outfile, 'write'): + outfile.write(output) + else: + with open(outfile, "wb") as f: + f.write(output) except IOError as msg: print(msg, file=sys.stderr)