Skip to content

Commit 09293bf

Browse files
committed
Work around subprocess EINTR bug; fixes issue #633
The bug http://bugs.python.org/issue12493 is present in some Python versions. The _read_nointr function has been unused since b03a908 (it did not work on Windows).
1 parent 2da9d8f commit 09293bf

File tree

2 files changed

+8
-12
lines changed

2 files changed

+8
-12
lines changed

CHANGELOG

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
2011-12-27 Work around an EINTR bug in some versions of subprocess. - JKS
2+
13
2011-08-18 Change api of Axes.get_tightbbox and add an optional
24
keyword parameter *call_axes_locator*. - JJL
35

lib/matplotlib/dviread.py

+6-12
Original file line numberDiff line numberDiff line change
@@ -835,23 +835,17 @@ def find_tex_file(filename, format=None):
835835

836836
matplotlib.verbose.report('find_tex_file(%s): %s' \
837837
% (filename,cmd), 'debug')
838-
pipe = subprocess.Popen(cmd, stdout=subprocess.PIPE)
838+
# stderr is unused, but reading it avoids a subprocess optimization
839+
# that breaks EINTR handling in some Python versions:
840+
# http://bugs.python.org/issue12493
841+
# https://github.com/matplotlib/matplotlib/issues/633
842+
pipe = subprocess.Popen(cmd, stdout=subprocess.PIPE,
843+
stderr=subprocess.PIPE)
839844
result = pipe.communicate()[0].rstrip()
840845
matplotlib.verbose.report('find_tex_file result: %s' % result,
841846
'debug')
842847
return result
843848

844-
def _read_nointr(pipe, bufsize=-1):
845-
while True:
846-
try:
847-
return pipe.read(bufsize)
848-
except OSError, e:
849-
if e.errno == errno.EINTR:
850-
continue
851-
else:
852-
raise
853-
854-
855849
# With multiple text objects per figure (e.g. tick labels) we may end
856850
# up reading the same tfm and vf files many times, so we implement a
857851
# simple cache. TODO: is this worth making persistent?

0 commit comments

Comments
 (0)