1. Doug Hellmann
  2. sphinx-graphviz-paragraphs

Commits

DasIch  committed 1cfc557

Use codecs.open with python 2.x in the MessageCatalogBuilder

  • Participants
  • Parent commits de31798
  • Branches default

Comments (0)

Files changed (1)

File sphinx/builders/intl.py

View file
 from collections import defaultdict
 from datetime import datetime
 from os import path
+from codecs import open
 
 from docutils import nodes
 
                 self.catalogs.iteritems(), "writing message catalogs... ",
                 lambda (section, _):darkgreen(section), len(self.catalogs)):
 
-            pofile = open(path.join(self.outdir, '%s.pot' % section), 'w')
+            pofp = path.join(self.outdir, section + '.pot')
+            pofile = open(pofp, 'w', encoding='utf-8')
             try:
                 pofile.write(POHEADER % data)
                 for message in messages:
                     message = message.replace(u'\\', ur'\\'). \
                                       replace(u'"', ur'\"')
                     pomsg = u'msgid "%s"\nmsgstr ""\n\n' % message
-                    pofile.write(pomsg.encode('utf-8'))
+                    pofile.write(pomsg)
             finally:
                 pofile.close()