From b08d6769c12e0d6d281771bb6570df77b0afe6be Mon Sep 17 00:00:00 2001 From: Eklavya Sharma Date: Sun, 24 Jul 2016 22:32:08 +0530 Subject: [PATCH] tools/zulip-export/zulip-export: Fix how files are opened. Instead of using codecs.open, use the builtin open in binary mode and write data after encoding it in utf-8. --- tools/run-mypy | 1 - tools/zulip-export/zulip-export | 5 ++--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/tools/run-mypy b/tools/run-mypy index 331beaeec0..0b4476c169 100755 --- a/tools/run-mypy +++ b/tools/run-mypy @@ -62,7 +62,6 @@ bots/githook-post-receive tools/deprecated/inject-messages/inject-messages tools/deprecated/review tools/update-deployment -tools/zulip-export/zulip-export """.split() exclude_scripts_py2 = [] # type: List[str] diff --git a/tools/zulip-export/zulip-export b/tools/zulip-export/zulip-export index ea5ee32072..5e19b88d82 100755 --- a/tools/zulip-export/zulip-export +++ b/tools/zulip-export/zulip-export @@ -25,7 +25,6 @@ from __future__ import print_function import sys import os.path import optparse -import codecs import time import json usage = """Export all messages on a given stream to a JSON dump. @@ -79,8 +78,8 @@ for msg in result['messages']: messages.append(msg) filename = "zulip-%s.json" % (options.stream,) -f = codecs.open(filename, encoding='utf-8', mode="wb") -f.write(json.dumps(messages, indent=0, sort_keys=False)) +f = open(filename, mode="wb") +f.write(json.dumps(messages, indent=0, sort_keys=False).encode('utf-8')) f.close() print("%d messages exported to %s" % (len(messages), filename,)) sys.exit(0)