#1131: try to make grapviz invocation more robust

This commit is contained in:
Georg Brandl 2013-03-30 17:35:02 +01:00
parent 6feb07951e
commit 34c8a68e74

View File

@ -164,20 +164,13 @@ def render_dot(self, code, options, format, prefix='graphviz'):
self.builder.config.graphviz_dot) self.builder.config.graphviz_dot)
self.builder._graphviz_warned_dot = True self.builder._graphviz_warned_dot = True
return None, None return None, None
wentWrong = False
try: try:
# Graphviz may close standard input when an error occurs, # Graphviz may close standard input when an error occurs,
# resulting in a broken pipe on communicate() # resulting in a broken pipe on communicate()
stdout, stderr = p.communicate(code) stdout, stderr = p.communicate(code)
except (OSError, IOError), err: except (OSError, IOError), err:
if err.errno != EPIPE: if err.errno not in (EPIPE, EINVAL):
raise raise
wentWrong = True
except IOError, err:
if err.errno != EINVAL:
raise
wentWrong = True
if wentWrong:
# in this case, read the standard output and standard error streams # in this case, read the standard output and standard error streams
# directly, to get the error message(s) # directly, to get the error message(s)
stdout, stderr = p.stdout.read(), p.stderr.read() stdout, stderr = p.stdout.read(), p.stderr.read()