merge in 0.5

This commit is contained in:
Georg Brandl 2009-01-03 11:33:44 +01:00
commit 6a8b0aa599
4 changed files with 17 additions and 5 deletions

View File

@ -87,6 +87,11 @@ New features added
Release 0.5.2 (in development)
==============================
* #81: Write environment and search index in a manner that is safe
from exceptions that occur during dumping.
* #80: Fix UnicodeErrors when a locale is set with setlocale().
Release 0.5.1 (Dec 15, 2008)
============================

View File

@ -8,7 +8,7 @@
This module is only kept for API compatibility; new code should
import these classes directly from the sphinx.builders package.
:copyright: 2008 by Georg Brandl.
:copyright: 2008-2009 by Georg Brandl.
:license: BSD, see LICENSE for details.
"""

View File

@ -5,7 +5,7 @@
Several HTML builders.
:copyright: 2007-2008 by Georg Brandl, Armin Ronacher.
:copyright: 2007-2009 by Georg Brandl, Armin Ronacher.
:license: BSD, see LICENSE for details.
"""
@ -495,11 +495,15 @@ class StandaloneHTMLBuilder(Builder):
def handle_finish(self):
self.info(bold('dumping search index... '), nonl=True)
self.indexer.prune(self.env.all_docs)
f = open(path.join(self.outdir, self.searchindex_filename), 'wb')
searchindexfn = path.join(self.outdir, self.searchindex_filename)
# first write to a temporary file, so that if dumping fails, the existing
# index won't be overwritten
f = open(searchindexfn + '.tmp', 'wb')
try:
self.indexer.dump(f, self.indexer_format)
finally:
f.close()
os.rename(searchindexfn + '.tmp', searchindexfn)
self.info('done')
self.info(bold('dumping object inventory... '), nonl=True)

View File

@ -5,7 +5,7 @@
Global creation environment.
:copyright: 2007-2008 by Georg Brandl.
:copyright: 2007-2009 by Georg Brandl.
:license: BSD, see LICENSE for details.
"""
@ -205,7 +205,9 @@ class BuildEnvironment:
self.set_warnfunc(None)
values = self.config.values
del self.config.values
picklefile = open(filename, 'wb')
# first write to a temporary file, so that if dumping fails, the existing
# environment won't be overwritten
picklefile = open(filename + '.tmp', 'wb')
# remove potentially pickling-problematic values from config
for key, val in vars(self.config).items():
if key.startswith('_') or \
@ -217,6 +219,7 @@ class BuildEnvironment:
pickle.dump(self, picklefile, pickle.HIGHEST_PROTOCOL)
finally:
picklefile.close()
os.rename(filename + '.tmp', filename)
# reset attributes
self.config.values = values
self.set_warnfunc(warnfunc)