mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Safeguard file.close() against failure.
This commit is contained in:
parent
3f6fa966d0
commit
4a197b29ce
@ -66,9 +66,11 @@ class MessageCatalogBuilder(Builder):
|
||||
self.catalogs.iteritems(), "writing message catalogs... ",
|
||||
lambda (section, _):darkgreen(section), len(self.catalogs)):
|
||||
pofile = open(path.join(self.outdir, '%s.pot' % section), 'w')
|
||||
try:
|
||||
pofile.write(POHEADER % self.config)
|
||||
for message in messages:
|
||||
message = message.replace(u'"', ur'\"')
|
||||
pomsg = u'msgid "%s"\nmsgstr ""\n\n' % message
|
||||
pofile.write(pomsg.encode('utf-8'))
|
||||
finally:
|
||||
pofile.close()
|
||||
|
Loading…
Reference in New Issue
Block a user