From: <jo...@us...> - 2008-11-09 14:00:50
|
Revision: 6383 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6383&view=rev Author: jouni Date: 2008-11-09 14:00:49 +0000 (Sun, 09 Nov 2008) Log Message: ----------- Fix a possible EINTR problem in dviread Modified Paths: -------------- trunk/matplotlib/CHANGELOG trunk/matplotlib/lib/matplotlib/dviread.py Modified: trunk/matplotlib/CHANGELOG =================================================================== --- trunk/matplotlib/CHANGELOG 2008-11-09 13:17:41 UTC (rev 6382) +++ trunk/matplotlib/CHANGELOG 2008-11-09 14:00:49 UTC (rev 6383) @@ -1,3 +1,6 @@ +2008-11-09 Fix a possible EINTR problem in dviread, which might help + when saving pdf files from the qt backend. - JKS + 2008-10-24 Added Jae Joon's fancy arrow, box and annotation enhancements -- see examples/pylab_examples/annotation_demo2.py Modified: trunk/matplotlib/lib/matplotlib/dviread.py =================================================================== --- trunk/matplotlib/lib/matplotlib/dviread.py 2008-11-09 13:17:41 UTC (rev 6382) +++ trunk/matplotlib/lib/matplotlib/dviread.py 2008-11-09 14:00:49 UTC (rev 6383) @@ -689,7 +689,9 @@ def __init__(self, filename): file = open(filename, 'rt') try: + matplotlib.verbose.report('Parsing TeX encoding ' + filename, 'debug-annoying') self.encoding = self._parse(file) + matplotlib.verbose.report('Result: ' + `self.encoding`, 'debug-annoying') finally: file.close() @@ -746,15 +748,33 @@ assert "'" not in filename cmd += "'" + filename + "'" + matplotlib.verbose.report('find_tex_file(%s): %s' \ + % (filename,cmd), 'debug') pipe = os.popen(cmd, 'r') - result = pipe.readline().rstrip() + result = "" + while True: + data = _read_nointr(pipe) + if data == "": + break + result += data pipe.close() + result = result.rstrip() - matplotlib.verbose.report('find_tex_file: %s -> %s' \ - % (filename, result), + matplotlib.verbose.report('find_tex_file result: %s' % result, 'debug') return result +def _read_nointr(pipe, bufsize=-1): + while True: + try: + return pipe.read(bufsize) + except OSError, e: + if e.errno == errno.EINTR: + continue + else: + raise + + # With multiple text objects per figure (e.g. tick labels) we may end # up reading the same tfm and vf files many times, so we implement a # simple cache. TODO: is this worth making persistent? This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |