mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Fix #3803: Sphinx crashes with invalid PO files
This commit is contained in:
parent
14426f9d38
commit
ffb84cb07e
1
CHANGES
1
CHANGES
@ -30,6 +30,7 @@ Bugs fixed
|
|||||||
* #3779: 'ImportError' in sphinx.ext.autodoc due to broken 'sys.meta_path'.
|
* #3779: 'ImportError' in sphinx.ext.autodoc due to broken 'sys.meta_path'.
|
||||||
Thanks to Tatiana Tereshchenko.
|
Thanks to Tatiana Tereshchenko.
|
||||||
* #3796: env.resolve_references() crashes when non-document node given
|
* #3796: env.resolve_references() crashes when non-document node given
|
||||||
|
* #3803: Sphinx crashes with invalid PO files
|
||||||
|
|
||||||
Testing
|
Testing
|
||||||
--------
|
--------
|
||||||
|
@ -35,11 +35,11 @@ from sphinx import addnodes
|
|||||||
from sphinx.io import SphinxStandaloneReader, SphinxDummyWriter, SphinxFileInput
|
from sphinx.io import SphinxStandaloneReader, SphinxDummyWriter, SphinxFileInput
|
||||||
from sphinx.util import logging
|
from sphinx.util import logging
|
||||||
from sphinx.util import get_matching_docs, FilenameUniqDict, status_iterator
|
from sphinx.util import get_matching_docs, FilenameUniqDict, status_iterator
|
||||||
from sphinx.util.nodes import WarningStream, is_translatable
|
from sphinx.util.nodes import is_translatable
|
||||||
from sphinx.util.osutil import SEP, ensuredir
|
from sphinx.util.osutil import SEP, ensuredir
|
||||||
from sphinx.util.i18n import find_catalog_files
|
from sphinx.util.i18n import find_catalog_files
|
||||||
from sphinx.util.console import bold # type: ignore
|
from sphinx.util.console import bold # type: ignore
|
||||||
from sphinx.util.docutils import sphinx_domains
|
from sphinx.util.docutils import sphinx_domains, WarningStream
|
||||||
from sphinx.util.matching import compile_matchers
|
from sphinx.util.matching import compile_matchers
|
||||||
from sphinx.util.parallel import ParallelTasks, parallel_available, make_chunks
|
from sphinx.util.parallel import ParallelTasks, parallel_available, make_chunks
|
||||||
from sphinx.util.websupport import is_commentable
|
from sphinx.util.websupport import is_commentable
|
||||||
@ -889,8 +889,7 @@ class BuildEnvironment(object):
|
|||||||
with open(doctree_filename, 'rb') as f:
|
with open(doctree_filename, 'rb') as f:
|
||||||
doctree = pickle.load(f)
|
doctree = pickle.load(f)
|
||||||
doctree.settings.env = self
|
doctree.settings.env = self
|
||||||
doctree.reporter = Reporter(self.doc2path(docname), 2, 5,
|
doctree.reporter = Reporter(self.doc2path(docname), 2, 5, stream=WarningStream())
|
||||||
stream=WarningStream(self._warnfunc))
|
|
||||||
return doctree
|
return doctree
|
||||||
|
|
||||||
def get_and_resolve_doctree(self, docname, builder, doctree=None,
|
def get_and_resolve_doctree(self, docname, builder, doctree=None,
|
||||||
|
@ -24,7 +24,7 @@ from sphinx.locale import _
|
|||||||
from sphinx.util import logging
|
from sphinx.util import logging
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
report_re = re.compile('^(.+?:\\d+): \\((DEBUG|INFO|WARNING|ERROR|SEVERE)/(\\d+)?\\) '
|
report_re = re.compile('^(.+?:(?:\\d+)?): \\((DEBUG|INFO|WARNING|ERROR|SEVERE)/(\\d+)?\\) '
|
||||||
'(.+?)\n?$')
|
'(.+?)\n?$')
|
||||||
|
|
||||||
if False:
|
if False:
|
||||||
|
@ -31,20 +31,6 @@ if False:
|
|||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class WarningStream(object):
|
|
||||||
|
|
||||||
def __init__(self, warnfunc):
|
|
||||||
# type: (Callable) -> None
|
|
||||||
self.warnfunc = warnfunc
|
|
||||||
self._re = re.compile(r'\((DEBUG|INFO|WARNING|ERROR|SEVERE)/[0-4]\)')
|
|
||||||
|
|
||||||
def write(self, text):
|
|
||||||
# type: (str) -> None
|
|
||||||
text = text.strip()
|
|
||||||
if text:
|
|
||||||
self.warnfunc(self._re.sub(r'\1:', text), None, '')
|
|
||||||
|
|
||||||
|
|
||||||
# \x00 means the "<" was backslash-escaped
|
# \x00 means the "<" was backslash-escaped
|
||||||
explicit_title_re = re.compile(r'^(.+?)\s*(?<!\x00)<(.*?)>$', re.DOTALL)
|
explicit_title_re = re.compile(r'^(.+?)\s*(?<!\x00)<(.*?)>$', re.DOTALL)
|
||||||
caption_ref_re = explicit_title_re # b/w compat alias
|
caption_ref_re = explicit_title_re # b/w compat alias
|
||||||
|
Loading…
Reference in New Issue
Block a user