From febfd6829c47452bd4c6710a85f6e151d8f3d7eb Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Sat, 16 Apr 2016 16:55:59 +0900 Subject: [PATCH] Fix #2436: Sphinx does not check version by :confval:`needs_sphinx` if loading extensions failed --- CHANGES | 1 + sphinx/application.py | 14 +++++++------- sphinx/config.py | 4 ++++ 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/CHANGES b/CHANGES index 37088fe98..a894b1308 100644 --- a/CHANGES +++ b/CHANGES @@ -12,6 +12,7 @@ Bugs fixed * #2370: the equations are slightly misaligned in LaTeX writer * #1817, #2077: suppress pep8 warnings on conf.py generated by sphinx-quickstart * #2407: building docs crash if document includes large data image URIs +* #2436: Sphinx does not check version by :confval:`needs_sphinx` if loading extensions failed Release 1.4.1 (released Apr 12, 2016) diff --git a/sphinx/application.py b/sphinx/application.py index c87ce5736..1ac64508a 100644 --- a/sphinx/application.py +++ b/sphinx/application.py @@ -133,6 +133,13 @@ class Sphinx(object): self.config.check_unicode(self.warn) # defer checking types until i18n has been initialized + # check the Sphinx version if requested + needs_sphinx = self.config.get_needs_sphinx() + if needs_sphinx and needs_sphinx > sphinx.__display_version__: + raise VersionRequirementError( + 'This project needs at least Sphinx v%s and therefore cannot ' + 'be built with this version.' % needs_sphinx) + # set confdir to srcdir if -C given (!= no confdir); a few pieces # of code expect a confdir to be set if self.confdir is None: @@ -163,13 +170,6 @@ class Sphinx(object): # now that we know all config values, collect them from conf.py self.config.init_values(self.warn) - # check the Sphinx version if requested - if self.config.needs_sphinx and \ - self.config.needs_sphinx > sphinx.__display_version__: - raise VersionRequirementError( - 'This project needs at least Sphinx v%s and therefore cannot ' - 'be built with this version.' % self.config.needs_sphinx) - # check extension versions if requested if self.config.needs_extensions: for extname, needs_ver in self.config.needs_extensions.items(): diff --git a/sphinx/config.py b/sphinx/config.py index e199e7ddc..5728b6d11 100644 --- a/sphinx/config.py +++ b/sphinx/config.py @@ -338,6 +338,10 @@ class Config(object): 'characters; this can lead to Unicode errors occurring. ' 'Please use Unicode strings, e.g. %r.' % (name, u'Content')) + def get_needs_sphinx(self): + """Obtain the value of ``needs_sphinx``""" + return self.overrides.get('needs_sphinx') or self._raw_config.get('needs_sphinx') + def init_values(self, warn): config = self._raw_config for valname, value in iteritems(self.overrides):