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... ",
|
self.catalogs.iteritems(), "writing message catalogs... ",
|
||||||
lambda (section, _):darkgreen(section), len(self.catalogs)):
|
lambda (section, _):darkgreen(section), len(self.catalogs)):
|
||||||
pofile = open(path.join(self.outdir, '%s.pot' % section), 'w')
|
pofile = open(path.join(self.outdir, '%s.pot' % section), 'w')
|
||||||
pofile.write(POHEADER % self.config)
|
try:
|
||||||
for message in messages:
|
pofile.write(POHEADER % self.config)
|
||||||
message = message.replace(u'"', ur'\"')
|
for message in messages:
|
||||||
pomsg = u'msgid "%s"\nmsgstr ""\n\n' % message
|
message = message.replace(u'"', ur'\"')
|
||||||
pofile.write(pomsg.encode('utf-8'))
|
pomsg = u'msgid "%s"\nmsgstr ""\n\n' % message
|
||||||
pofile.close()
|
pofile.write(pomsg.encode('utf-8'))
|
||||||
|
finally:
|
||||||
|
pofile.close()
|
||||||
|
Loading…
Reference in New Issue
Block a user