Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b03a908

Browse files
committed
Use subprocess.Popen instead of os.popen in dviread
(Windows problem reported by Jorgen Stenarson) svn path=/trunk/matplotlib/; revision=6565
1 parent 2ab883b commit b03a908

2 files changed

Lines changed: 10 additions & 17 deletions

File tree

CHANGELOG

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
2008-12-11 Use subprocess.Popen instead of os.popen in dviread
2+
(Windows problem reported by Jorgen Stenarson) - JKS
3+
14
2008-12-10 Added Michael's font_manager fix and Jae-Joon's
25
figure/subplot fix. Bumped version number to 0.98.5 - JDH
36

lib/matplotlib/dviread.py

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
import matplotlib
2222
import matplotlib.cbook as mpl_cbook
2323
import numpy as np
24-
import os
2524
import struct
25+
import subprocess
2626

2727
_dvistate = mpl_cbook.Bunch(pre=0, outer=1, inpage=2, post_post=3, finale=4)
2828

@@ -742,25 +742,15 @@ def find_tex_file(filename, format=None):
742742
doesn't use kpathsea, so what do we do? (TODO)
743743
"""
744744

745-
cmd = 'kpsewhich '
745+
cmd = ['kpsewhich']
746746
if format is not None:
747-
assert "'" not in format
748-
cmd += "--format='" + format + "' "
749-
assert "'" not in filename
750-
cmd += "'" + filename + "'"
751-
747+
cmd += ['--format=' + format]
748+
cmd += [filename]
749+
752750
matplotlib.verbose.report('find_tex_file(%s): %s' \
753751
% (filename,cmd), 'debug')
754-
pipe = os.popen(cmd, 'r')
755-
result = ""
756-
while True:
757-
data = _read_nointr(pipe)
758-
if data == "":
759-
break
760-
result += data
761-
pipe.close()
762-
result = result.rstrip()
763-
752+
pipe = subprocess.Popen(cmd, stdout=subprocess.PIPE)
753+
result = pipe.communicate()[0].rstrip()
764754
matplotlib.verbose.report('find_tex_file result: %s' % result,
765755
'debug')
766756
return result

0 commit comments

Comments
 (0)