From d997aa76b0b2ea3a3caf9d2bcd33e4e10bac73d3 Mon Sep 17 00:00:00 2001 From: Jonathan Waltman Date: Thu, 3 Jan 2013 13:34:47 -0600 Subject: [PATCH 1/2] Closes #958: Do not preserve ``environment.pickle`` after a failed build. --- CHANGES | 2 ++ sphinx/application.py | 5 +++++ sphinx/environment.py | 5 +---- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/CHANGES b/CHANGES index 03a83d4f8..af15c8861 100644 --- a/CHANGES +++ b/CHANGES @@ -62,6 +62,8 @@ Release 1.2 (in development) * #1041: Fix cpp domain parser fails to parse a const type with a modifier. +* #958: Do not preserve ``environment.pickle`` after a failed build. + * PR#88: Added the "Sphinx Developer's Guide" (:file:`doc/devguide.rst`) which outlines the basic development process of the Sphinx project. diff --git a/sphinx/application.py b/sphinx/application.py index 9cf90f1dd..6eefc3e44 100644 --- a/sphinx/application.py +++ b/sphinx/application.py @@ -11,6 +11,7 @@ :license: BSD, see LICENSE for details. """ +import os import sys import types import posixpath @@ -203,6 +204,10 @@ class Sphinx(object): else: self.builder.build_update() except Exception, err: + # delete the saved env to force a fresh build next time + envfile = path.join(self.doctreedir, ENV_PICKLE_FILENAME) + if path.isfile(envfile): + os.unlink(envfile) self.emit('build-finished', err) raise else: diff --git a/sphinx/environment.py b/sphinx/environment.py index 5103be6a8..5caa09eb8 100644 --- a/sphinx/environment.py +++ b/sphinx/environment.py @@ -365,9 +365,7 @@ class BuildEnvironment: del self.config.values domains = self.domains del self.domains - # first write to a temporary file, so that if dumping fails, - # the existing environment won't be overwritten - picklefile = open(filename + '.tmp', 'wb') + picklefile = open(filename, 'wb') # remove potentially pickling-problematic values from config for key, val in vars(self.config).items(): if key.startswith('_') or \ @@ -379,7 +377,6 @@ class BuildEnvironment: pickle.dump(self, picklefile, pickle.HIGHEST_PROTOCOL) finally: picklefile.close() - movefile(filename + '.tmp', filename) # reset attributes self.domains = domains self.config.values = values From cf4166fa58b8dd895c38d7e42ef391e06f8d9bf3 Mon Sep 17 00:00:00 2001 From: Jonathan Waltman Date: Thu, 3 Jan 2013 13:55:26 -0600 Subject: [PATCH 2/2] Fix ``test_i18n_literalblock_warning`` which would sometimes fail due to the text wrapping of error messages. --- tests/test_intl.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_intl.py b/tests/test_intl.py index 545d9c559..decffa91b 100644 --- a/tests/test_intl.py +++ b/tests/test_intl.py @@ -219,7 +219,7 @@ def test_i18n_literalblock_warning(app): u"\n this is" u"\n literal block\n" u"\nMISSING LITERAL BLOCK:\n" - u"\n