mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Fix #5493: gettext: crashed with broken template
This commit is contained in:
parent
9875a57622
commit
ef134fb142
1
CHANGES
1
CHANGES
@ -19,6 +19,7 @@ Bugs fixed
|
|||||||
* #5490: latex: enumerated list causes a crash with recommonmark
|
* #5490: latex: enumerated list causes a crash with recommonmark
|
||||||
* #5492: sphinx-build fails to build docs w/ Python < 3.5.2
|
* #5492: sphinx-build fails to build docs w/ Python < 3.5.2
|
||||||
* #3704: latex: wrong ``\label`` positioning for figures with a legend
|
* #3704: latex: wrong ``\label`` positioning for figures with a legend
|
||||||
|
* #5493: gettext: crashed with broken template
|
||||||
|
|
||||||
Testing
|
Testing
|
||||||
--------
|
--------
|
||||||
|
@ -22,6 +22,7 @@ from six import iteritems, StringIO
|
|||||||
|
|
||||||
from sphinx.builders import Builder
|
from sphinx.builders import Builder
|
||||||
from sphinx.domains.python import pairindextypes
|
from sphinx.domains.python import pairindextypes
|
||||||
|
from sphinx.errors import ThemeError
|
||||||
from sphinx.locale import __
|
from sphinx.locale import __
|
||||||
from sphinx.util import split_index_msg, logging, status_iterator
|
from sphinx.util import split_index_msg, logging, status_iterator
|
||||||
from sphinx.util.console import bold # type: ignore
|
from sphinx.util.console import bold # type: ignore
|
||||||
@ -247,11 +248,14 @@ class MessageCatalogBuilder(I18nBuilder):
|
|||||||
|
|
||||||
for template in status_iterator(files, __('reading templates... '), "purple", # type: ignore # NOQA
|
for template in status_iterator(files, __('reading templates... '), "purple", # type: ignore # NOQA
|
||||||
len(files), self.app.verbosity):
|
len(files), self.app.verbosity):
|
||||||
with open(template, 'r', encoding='utf-8') as f: # type: ignore
|
try:
|
||||||
context = f.read()
|
with open(template, 'r', encoding='utf-8') as f: # type: ignore
|
||||||
for line, meth, msg in extract_translations(context):
|
context = f.read()
|
||||||
origin = MsgOrigin(template, line)
|
for line, meth, msg in extract_translations(context):
|
||||||
self.catalogs['sphinx'].add(msg, origin)
|
origin = MsgOrigin(template, line)
|
||||||
|
self.catalogs['sphinx'].add(msg, origin)
|
||||||
|
except Exception as exc:
|
||||||
|
raise ThemeError('%s: %r' % (template, exc))
|
||||||
|
|
||||||
def build(self, docnames, summary=None, method='update'):
|
def build(self, docnames, summary=None, method='update'):
|
||||||
# type: (Iterable[unicode], unicode, unicode) -> None
|
# type: (Iterable[unicode], unicode, unicode) -> None
|
||||||
|
Loading…
Reference in New Issue
Block a user