Fix #4279: Sphinx crashes with pickling error when run with multiple processes and remote image

This commit is contained in:
Takeshi KOMIYA 2017-12-10 21:10:56 +09:00
parent 90ee039e34
commit 38b5dff206
2 changed files with 20 additions and 9 deletions

View File

@ -24,6 +24,8 @@ Bugs fixed
* #2298: automodule fails to document a class attribute * #2298: automodule fails to document a class attribute
* #4099: C++: properly link class reference to class from inside constructor * #4099: C++: properly link class reference to class from inside constructor
* #4267: PDF build broken by Unicode U+2116 NUMERO SIGN character * #4267: PDF build broken by Unicode U+2116 NUMERO SIGN character
* #4279: Sphinx crashes with pickling error when run with multiple processes and
remote image
Testing Testing
-------- --------

View File

@ -82,6 +82,10 @@ def convert_serializable(records):
r.msg = r.getMessage() r.msg = r.getMessage()
r.args = () r.args = ()
location = getattr(r, 'location', None)
if isinstance(location, nodes.Node):
r.location = get_node_location(location)
class SphinxWarningLogRecord(logging.LogRecord): class SphinxWarningLogRecord(logging.LogRecord):
"""Log record class supporting location""" """Log record class supporting location"""
@ -415,21 +419,26 @@ class WarningLogRecordTranslator(logging.Filter):
else: else:
record.location = None record.location = None
elif isinstance(location, nodes.Node): elif isinstance(location, nodes.Node):
(source, line) = get_source_line(location) record.location = get_node_location(location)
if source and line:
record.location = "%s:%s" % (source, line)
elif source:
record.location = "%s:" % source
elif line:
record.location = "<unknown>:%s" % line
else:
record.location = None
elif location and ':' not in location: elif location and ':' not in location:
record.location = '%s' % self.app.env.doc2path(location) record.location = '%s' % self.app.env.doc2path(location)
return True return True
def get_node_location(node):
# type: (nodes.Node) -> str
(source, line) = get_source_line(node)
if source and line:
return "%s:%s" % (source, line)
elif source:
return "%s:" % source
elif line:
return "<unknown>:%s" % line
else:
return None
class ColorizeFormatter(logging.Formatter): class ColorizeFormatter(logging.Formatter):
def format(self, record): def format(self, record):
# type: (logging.LogRecord) -> str # type: (logging.LogRecord) -> str