graphviz: also catch IOError with Errno 22 (invalid parameter)

This happen on Python2.7 and Graphviz version 2.12 (Mon Dec  4 22:04:37 UTC 2006)
on Windows when a not recognized renderer type is asked.
This commit is contained in:
Benoit Allard
2011-07-14 16:57:01 +02:00
parent db733f40fc
commit 9350b3b46b
2 changed files with 9 additions and 1 deletions

View File

@@ -25,7 +25,7 @@ from docutils import nodes
from docutils.parsers.rst import directives
from sphinx.errors import SphinxError
from sphinx.util.osutil import ensuredir, ENOENT, EPIPE
from sphinx.util.osutil import ensuredir, ENOENT, EPIPE, EINVAL
from sphinx.util.compat import Directive
@@ -163,6 +163,7 @@ def render_dot(self, code, options, format, prefix='graphviz'):
self.builder.config.graphviz_dot)
self.builder._graphviz_warned_dot = True
return None, None
wentWrong = False
try:
# Graphviz may close standard input when an error occurs,
# resulting in a broken pipe on communicate()
@@ -170,6 +171,12 @@ def render_dot(self, code, options, format, prefix='graphviz'):
except OSError, err:
if err.errno != EPIPE:
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
# directly, to get the error message(s)
stdout, stderr = p.stdout.read(), p.stderr.read()

View File

@@ -21,6 +21,7 @@ from os import path
EEXIST = getattr(errno, 'EEXIST', 0)
ENOENT = getattr(errno, 'ENOENT', 0)
EPIPE = getattr(errno, 'EPIPE', 0)
EINVAL = getattr(errno, 'EINVAL', 0)
# SEP separates path elements in the canonical file names
#