diff --git a/CHANGES b/CHANGES index bbb7e8cc7..a15b43409 100644 --- a/CHANGES +++ b/CHANGES @@ -19,6 +19,7 @@ Bugs fixed * #4769: autodoc loses the first staticmethod parameter * #4790: autosummary: too wide two column tables in PDF builds * #4795: Latex customization via ``_templates/longtable.tex_t`` is broken +* #4789: imgconverter: confused by convert.exe of Windows Testing -------- diff --git a/sphinx/ext/imgconverter.py b/sphinx/ext/imgconverter.py index 95f579e36..d7a324a8e 100644 --- a/sphinx/ext/imgconverter.py +++ b/sphinx/ext/imgconverter.py @@ -37,17 +37,28 @@ class ImagemagickConverter(ImageConverter): try: args = [self.config.image_converter, '-version'] logger.debug('Invoking %r ...', args) - ret = subprocess.call(args, stdin=subprocess.PIPE, stdout=subprocess.PIPE) - if ret == 0: - return True - else: - return False + p = subprocess.Popen(args, stdin=subprocess.PIPE, stdout=subprocess.PIPE) except (OSError, IOError): logger.warning(__('convert command %r cannot be run.' 'check the image_converter setting'), self.config.image_converter) return False + try: + stdout, stderr = p.communicate() + except (OSError, IOError) as err: + if err.errno not in (EPIPE, EINVAL): + raise + stdout, stderr = p.stdout.read(), p.stderr.read() + p.wait() + if p.returncode != 0: + logger.warning(__('convert exited with error:\n' + '[stderr]\n%s\n[stdout]\n%s'), + (stderr, stdout)) + return False + + return True + def convert(self, _from, _to): # type: (unicode, unicode) -> bool """Converts the image to expected one."""