From 0b001716558cf3c881f51f310d753e57cfd8920f Mon Sep 17 00:00:00 2001 From: Virgil Dupras Date: Sun, 24 Nov 2013 10:22:05 -0500 Subject: [PATCH] pygettext: explicitly open files as utf-8 When running it through SSH, I couldn't open files with non-ascii chars. --- hscommon/pygettext.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/hscommon/pygettext.py b/hscommon/pygettext.py index 5d2305ba..ad3157b6 100755 --- a/hscommon/pygettext.py +++ b/hscommon/pygettext.py @@ -378,7 +378,7 @@ def main(source_files, outpath, keywords=None): # initialize list of strings to exclude if options.excludefilename: try: - fp = open(options.excludefilename) + fp = open(options.excludefilename, encoding='utf-8') options.toexclude = fp.readlines() fp.close() except IOError: @@ -392,7 +392,7 @@ def main(source_files, outpath, keywords=None): for filename in source_files: if options.verbose: print('Working on %s' % filename) - fp = open(filename) + fp = open(filename, encoding='utf-8') closep = 1 try: eater.set_filename(filename) @@ -408,7 +408,7 @@ def main(source_files, outpath, keywords=None): if closep: fp.close() - fp = open(options.outfile, 'w') + fp = open(options.outfile, 'w', encoding='utf-8') closep = 1 try: eater.write(fp)